tags:

views:

849

answers:

2

actually the title is the whole question...

i just want to modify the template so that the current page title is automaticly shown (i'm working with html templates so I just need the bit of typoscript to get the page title out of the database)

i hope that's possible and somebody knows how

+2  A: 

It is. It's pretty simple to do. I'll assume you're using TemplaVoila, becase if you're not, you should be :-D

Start off by putting some HTML in your template with a dummy page title. Give it an ID attribute so it's easy to map. Like:

<h1 id="page-title">Page Title Here</h1>

Next, go into TemplaVoila and map that <h1> element to the content type "TypoScript Object Path". When it prompts you for the object path, you can put in anything you want -- convention is that dynamic content is added in the "lib" namespace, so let's call it lib.pagetitle. (Omit that period at the end there.) When it asks you if you want to map this to "INNER" or "OUTER", choose "INNER" -- that will mean you're just mapping the space BETWEEN the <h1>...</h1> tags. ("OUTER" means you're replacing the whole element, including the tags, which we don't want here because we want this to stay an H1.) Save your template mapping.

Now go into your site's TypoScript template. Here you're going to insert the logic that fills in that space we just mapped with actual content. To insert the page title is a matter of a couple of lines of TypoScript:

lib.pagetitle = TEXT
lib.pagetitle.data = page : title

What this says is "take the space in the template that I mapped to lib.pagetitle. Create a content object in that space of type TEXT. Then fill that content object with the title of the page."

Save your TypoScript template. Now you're done!

This probably sounds complicated at first glance, and it is, but the nice thing about this system is that it's amazingly flexible. Inserting text dynamically is just the beginning. The TSRef has all the details -- look up "getText" to get a flavor, that's the function that makes the "page : title" call in your TypoScript template drop in the page title.

TSRef is your friend. I keep a printed copy of it at my desk -- if you want to make TYPO3 sing, it is your songbook.

jalefkowit
Thank you for that nice tutorial!I tried to find such a function in the TSRef - but I didn't (also i can't find getText at the moment) so I will keep on searching :)
Daniel Scheidl
Yeah, it can be hard to find specific stuff in the TSRef. I had tried to include a direct link to getText but SO wouldn't let me b/c I'm new here. It's on this page:http://typo3.org/documentation/document-library/references/doc_core_tsref/4.2.1/view/1/2/#id4252676
jalefkowit
I keep a printed copy with my own keywords and markings. Old school, I know, but it works!
jensgram
A: 

thank u very much for the great tips

Sazzad