[TYPO3-templavoila] Automatic hiding of unused content area...

Chris chris at oblady.com
Sat Jan 24 20:13:59 CET 2009


Very nice !

by the way you made me figure out how to use the LOAD_REGISTER cObject :-)
that's a real good example

cheers,

Chris

Stig Nørgaard Færch a écrit :
> Just for anyone who might be interested.
> 
> On a project that I'm currently working on, I have added a simple but 
> cool feature to Templavoila by typoscript.
> 
> Usually when we have a site with a layout which is 3 columns on the 
> frontpage and 2/3 columns on the subpages, we 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.
> The CSS hides #right and makes #normal wider and gives it a different 
> margin-right.
> 
> That's it. Hope it will be useful to some of you.
> 
> /Stig


More information about the TYPO3-project-templavoila mailing list