We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50923
    • 137 Posts
    I have started working on some website, but to go in way to use only one template for every page.
    Practice is like this

    <body class="page  page-template-default header_2 fixed_slider">
        <!-- Header -->
        [[$_Header]]
        <!-- End Header -->
        <div class="top_wrapper">
        [[!If?
           &subject=`[[*id]]`
           &operator=`EQ`
           &operand=`1`
           &then=`[[$_HomeCarousel]]`
           &else=`[[$_PageHeader]]`
        ]]
            <section id="content" class="page-dynamic_template-home sequentialchildren container ">
             [[!If?
               &subject=`[[*id]]`
               &operator=`EQ`
               &operand=`1`
               &then=`[[$_HomeCarouselText]]`
            ]]
    </section>
    </div>
    </body>


    Is this good practice to development or maybe to create another template?
      <a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>
      • 4172
      • 5,888 Posts
      I would create a Chunk, which holds the template-code for all different templates
      named 'baseTemplate'

      <body class="page  page-template-default header_2 fixed_slider">
          <!-- Header -->
          [[$_Header]]
          <!-- End Header -->
          <div class="top_wrapper">
          [[$[[+pageHeader]]]]
          <section id="content" class="page-dynamic_template-home sequentialchildren container ">
             [[$[[+contentChunk]]]]
          </section>
      </div>
      </body>


      Then have different Templates like that:

      [[$baseTemplate?
      &pageHeader=`_HomeCarusel`
      &contentChunk=`_HomeCarouselText`
      ]]


      [[$baseTemplate?
      &pageHeader=`_PageHeader`
      &contentChunk=``
      ]]


      Better to have different Templates, than using many if-statements.

      If you still want to use IF-statements, call them cached and make sure the code inside isn't processed, if not necessary, so it would look like that.

          [[[[If?
             &subject=`[[*id]]`
             &operator=`EQ`
             &operand=`1`
             &then=`$_HomeCarousel`
             &else=`$_PageHeader`
          ]]]]
      


      See also
      http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!