We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46448
    • 98 Posts
    For sites with a lot of pages where navigation and/or footer info may need to be changed:

    ...is it smarter to create a header (with navigation), and a footer, (each with a CSS file linked), and make them into separate "include" files?

    If yes, then would a Revolution template be as simple as a php file with 2 lines, like this:

    <?php include 'header.php'; ?>
    
    Content here
    
    <?php include 'footer.php'; ?>
    


    If this is not correct, can you give (or point to) a quick example of the correct way to do this? And finally, are there any "gotchas" you can think of?

    Thanks!

    Dennis

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      you can not use php-code directly in a template or chunk, but you can use chunks for the header and footer

      [[$header]]
      
      Content here
      
      [[$footer]]


      or snippets, which can include php-files:

      [[include? &include=`header.php`]]
      
      Content here
      
      [[include? &include=`footer.php`]]


        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 46448
        • 98 Posts
        Thanks for the quick reply, Bruno17. So, it looks like the way to go is using snippets, if the header and footer need to have any php database functionality, and if not, chuncks would work, and the chunk would be a chunk of HTML, with a link href to the css file.

        Dennis
        • discuss.answer
          • 10208 ☆ A M B ☆
          • 1,780 Posts
          It's easiest to use chunks for the head and footer (not snippets), and then within the chunks if you need php, use snippets that contain your php.

          So, your template could theoretically look something like this:

          [[$head]]
          [[$header]]
          [[$menu]]
          [[*content]] (this comes from the resource/page content field which is actually a TV)
          [[$footer]]

          Yes, the chunks can contain all the html you want and the head chunk usually contains all the bits from your <head>all your head stuff</head>. You can even use chunks and TVs within chunks and TVs. Watch the number of db requests though, if you don't really need a chunk don't bother with it.

          Sometimes breaking everything in the template up into chunks can be confusing, it's easy to end up with stray or missing </div>s, etc. Letting the template contain html that is not in chunks often helps keep all that straight. Anything that you want to be able to change dynamically across multiple templates however, a single chunk is a great choice.

          Any time you need php, make a snippet, name it, place the php within, and call it wherever you like (chunks, TVs, resource content field).

          Snippet tag syntax is: [[snippet_name]]
            Frogabog- MODX Websites in Portland Oregon
            "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
            Having server issues? These guys have MODX Hosting perfected - SkyToaster
            • 46448
            • 98 Posts
            Excellent, Frogabog! Thanks for expanding on the topic!

            Dennis