We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22393
    • 6 Posts
    Hi Guys,
    I just wanted to ask if you guys knew of a cool way to have a snippet in the header which displays a different banner image depending on what folder the content is in. Each parent folder has a banner image created for it, and all of its children show that banner image.

    for example

    cars (folder)
    - holden (shows the ’cars’ banner at the top)
    - ford (shows the ’cars’ banner at the top)

    engines
    - V4 (shows the ’engines’ banner at the top)
    - V6 (shows the ’engines’ banner at the top)


    thanks for your help guys!

    Nicholas
      • 4310
      • 2,310 Posts
      Quick fix is add this wherever you want your banner:
      <img src="assets/images/[*parent*].jpg">

      Where the name of your banner jpg is the doc id number of the parent doc.
      So if cars = 11 then the car banner is 11.jpg
      There are more sophisticated solutions out there!
        • 4041
        • 788 Posts
        Not the most elegant solution and untested but this may work smiley
        <?php
        // sample parent folder numbers used later
        // cars_pageid = 4
        // engines_id  = 5
        
        $output ="";
        $current_pageid = $modx->documentIdentifier;
        $current_pageid_parent =$modx->documentObject['parent'];
        
        // change these samples to the ids of your parent documents
        
        if($current_pageid == "4" || $current_pageid_parent == "4"){
          $output .="<img src='path/to/your/cars/image' alt=''>";
        }
        
        if($current_pageid == "5" || $current_pageid_parent == "5"){
          $output .="<img src='path/to/your/engines/image' alt=''>";
        }
        
        return $output;
        ?>
          xforum
          http://frsbuilders.net (under construction) forum for evolution
          • 22393
          • 6 Posts
          breezer and bunk58 thank you guys very much for helping me with this one.
          have a good one!