We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43965
    • 23 Posts
    Hi i have a <div> in a template containing some content. I would like to show this <div> only in the homepage and not the rest. How I can do this please? Thanks
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      There are a number of ways you can do this (as is usual with MODx).

      1. Have a separate template for the Home page (after years of experience, this has become my preferred way of handling the common differences for the home page on most sites - while it's fun to shoehorn an entire site into one template using TVs, output modifiers and CSS, it's not really practical).

      2. Use a Template Variable, with the default left empty, and just add the div and the content in the TV for the home page.

      3. Put the div and content in a chunk, and use an Output Modifier in the template where you want it:
      [[[[*id:is=`1`:then=`$HomeChunk`:else=``]]]]
      

      This awkward-looking structure is best explained here http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 43965
        • 23 Posts
        Thanks a lot for your interesting reply. So I created a TV banner_bar which is a dropdown list. I wrapped the code I want to display based on banner_bar. It is working and it is showing on one page (the homepage), however when I switch to german language (using babel), this is not working even though it is set to show. So to cut the story short, the code below it is only working when on english. Can you help me fixing this please? Thanks a lot.

        [[*banner_bar:is=`Show`:then=`
        	<div id="sub-banner">
        	   <div class="inner">
        		<div class="space-left" style="background-image:url(assets/templates/comminform/images/sub-banner-sep.png); background-repeat: no-repeat; background-position: right center;">
        			<h2>[[%welcometo? &namespace=`babel`]]</h2>
        			<p>[[%welcomeparagraph? &namespace=`babel`]]</p>
        		</div>
        
        		<div class="space-right">
        			<h3>[[%ourclients? &namespace=`babel`]]</h3>
        			<p><img src="imgs/client-logos.png"/></p>
        		</div>
        	   </div>
        	</div>
        `:else=``]]


        Quote from: sottwell at Aug 14, 2013, 09:29 AM
        There are a number of ways you can do this (as is usual with MODx).

        1. Have a separate template for the Home page (after years of experience, this has become my preferred way of handling the common differences for the home page on most sites - while it's fun to shoehorn an entire site into one template using TVs, output modifiers and CSS, it's not really practical).

        2. Use a Template Variable, with the default left empty, and just add the div and the content in the TV for the home page.

        3. Put the div and content in a chunk, and use an Output Modifier in the template where you want it:
        [[[[*id:is=`1`:then=`$HomeChunk`:else=``]]]]
        

        This awkward-looking structure is best explained here http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/