This page is still a beta!

Filter options

Category

Search

Reset

Add snippet

If you would like to create a new snippet, please click here:

Add snippet

Automatic hiding of unused content area...

Author Tags Category Date
Stig Nørgaard Færch

2 snippets

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.

  1. This is the typoscript in the datastructure on the field/area which I want to hide if it is empty:
  2. <TypoScript><![CDATA[
  3. 10= RECORDS
  4. 10.source.current=1
  5. 10.tables = tt_content
  6. 10.stdWrap.ifEmpty{
  7. cObject = LOAD_REGISTER
  8. cObject.rightContentEmpty = 1
  9. }
  10. 10.stdWrap {
  11. required = 1
  12. wrap = <!--TYPO3SEARCH_begin--> | <!--TYPO3SEARCH_end-->
  13. }
  14. ]]></TypoScript>
  15. So here I say that if there is no content the register should add rightContentEmpty with a value of 1.
  16.  
  17. In my typoscript template (setup field), I add the following code:
  18. page.headerData.1001 = TEXT
  19. page.headerData.1001 {
  20. value (
  21. <style type="text/css">
  22. /*<![CDATA[*/
  23. #right {display:none;} #normal {width: 501px; margin-right: 33px;}
  24. /*]]>*/
  25. </style>
  26. )
  27. if.isTrue.data = register:rightContentEmpty
  28. }
  29. So if rightContentEmpty is true, then the css will be added with the headerData.
Copy to Clipboard