Typoscript "slide" functionality lets sub pages inherit parent's field values
I have some pages in my site tree for which I want them to display some data from the "keywords" field of the page. The only problem is that I don't enter keywords for every page. For such pages where keywords have not been entered into the "keywords" field, I would like them to inherit the keywords from their parent page. And if there's no keywords in the parent page, I would like to inherit the keywords from the parent's parent. And so on and so forth.
This I understood could be done using the "slide" property in typoscript, a property that's been available for a while. The only slide functionality I've ever used up to this point was the "slide" feature available in Templavoila, which is excellent, by the way.
So I Googled for some sample typoscript code which I could customize to suit my needs of allowing pages to inherit the value of the "keywords" field from parent pages. And what follows is some code that I modified to suit my purposes.
temp.slide = TEXT
temp.slide.data = levelfield : -1, keywords, slide
page.20 < temp.slide
I pasted that typoscript into my pages, then I loaded a page which had keywords in the front end, and then I saw that my keywords appeared. That was good.
What was not good is that when I visited a subpage which didn't have any keywords assigned, nothing was displayed. The keywords didn't slide down from the parent as was desired.
After more searching on Google, I found the keyword field (and other fields as well) need to be enabled for "sliding". In other words, fields from the pages table aren't going to slide unless TYPO3 is configured to allow them to. That's kind of good, I guess.
So, to make the typoscript code I presented earlier work, only one more thing has to be done. And that is to:
- Go to the Install tool
- From the Install tool, go to the "All Configuration" section.
- Find the section which says: [addRootLineFields]Comma-list of fields from the 'pages'-table. These fields are added to the select query for fields in the rootline.
- Add the field that you would like to "slide" to the comma separated list of fields.
- Click on Write to localconf.php
Now, whatever field from the pages table you added to the list of fields in the steps above will be "slideable" (is slideable actually a word?).
I wish that I would have learned about this functionality sooner. I'd also like it if there's some kind of override feature that would allow by default the sliding of all fields of the pages table.
I can't wait to play around with the "slide" property of typoscript. Ideas for it's use are already popping into my mind.