We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37142
    • 4 Posts
    Hi im a beginner so hopefully people can understand what im asking...

    I am creating templates for a website. At the moment I have created multiple templates for something which I think I can use just one single template with the addition of template variables.

    e.g at the moment I have created 2 templates for the following: a blank version and a version which will have an image at the top left.

    1) Do I create a single template with template variables? Or create 2 separate templates?
    2) Here is the code for the template with the image

    [[$header]]
    <div id="main-reg">
    <h1>
    [[*pagetitle]]
    </h1>
    <div class="extra-image">
         <img src="[[*extra-image]]"/>
    </div>
    [[*content]]			
    </div>
    [[$footer]]
    



    The problem I have is that if I use this template on a page with no image I get a small space (as shown) where the image would have been. What do I do?

    Thanks!
      • 10487 MODX Staff
      • 1,535 Posts
      You could use the 'notempty' output filter to control the display of the image div, for example:

      [[*extra-image:notempty=`
      <div class="extra-image">
           <img src="[[*extra-image]]"/>
      </div>
      `]]
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 37142
        • 4 Posts
        great this might be what i was looking for. cheers