Automatic hiding of unused content area...
| Author | Tags | Category | Date |
|---|---|---|---|
Stig Nørgaard Færch |
templavoila, BE, LOAD_REGISTER, TV | typoscript | February 04, 2009 |
When you have a site layout which is 3 columns on the frontpage and 2/3 columns on the subpages, you could create two datastructures.
The problem is that it is not very intuitive for the user to change from 2 to 3 columns on a subpage, as he has to both change a datastructure and the template.
So instead of going for two datastructures, I have managed to hide the 3rd column if it is empty.
So the thing that decides if the 3rd column is shown, is if I have put any content in it.
This is the typoscript in the datastructure on the field/area which I want to hide if it is empty: <TypoScript><![CDATA[ 10= RECORDS 10.source.current=1 10.tables = tt_content 10.stdWrap.ifEmpty{ cObject = LOAD_REGISTER cObject.rightContentEmpty = 1 } 10.stdWrap { required = 1 wrap = <!--TYPO3SEARCH_begin--> | <!--TYPO3SEARCH_end--> } ]]></TypoScript> So here I say that if there is no content the register should add rightContentEmpty with a value of 1. In my typoscript template (setup field), I add the following code: page.headerData.1001 = TEXT page.headerData.1001 { value ( <style type="text/css"> /*<![CDATA[*/ #right {display:none;} #normal {width: 501px; margin-right: 33px;} /*]]>*/ </style> ) if.isTrue.data = register:rightContentEmpty } So if rightContentEmpty is true, then the css will be added with the headerData.
Copy to Clipboard