Passing a shared region into a template. Possible?

  • I'm not sure this is possible and there might be a better way to implement. This is a Perch project (not Runway).


    My client has a number of locations, let's call them 1 to 7.


    When someone is viewing location 1, there needs to be a bar displaying locations 2 to 7. When on location 2, the bar needs to display 1, 3, 4, 5, 6 and 7 etc.


    In the absence of collections. I was thinking I could have a template which lists all the locations (other_locations.html) and have that as a shared region. Hence the client only has to input the data once.


    In a separate template (display_locations.html), I was thinking I could use checkboxes for each location. Hence when on location 1, the client could click the locations 2 - 7 to display them. These would refer to perch:if exists which surround the Locations.


    I made a test template just to show both templates in a single working template. And that looks like this:


    It is possible in the location.php master page template to somehow, allow other_locations.html to be a shared region, and then pass it into display_locations.html


    Hope this make sense :/

  • In the absence of collections. I was thinking I could have a template which lists all the locations (other_locations.html) and have that as a shared region. Hence the client only has to input the data once.


    The closest thing to a collection in regular Perch is a multiple-item region. You can display the region on any page using the page option:


    PHP
    1. perch_content_custom('Locations', [
    2. 'page'=>'/locations/index.php',
    3. 'template'=>'locations_list.html',
    4. ]);


    Collections are more powerful, but you get a lot of the same features like filtering. So if you are viewing the detail page of location 2, you can list the other locations and exclude location 2 with a filter. Assuming each location has a slug:


  • Thanks Hussein,


    I've been playing with this and I'm little stuck!


    Here is what I have.


    HTML: /content/location/location_list.html
    1. <div class="cell-sm-9 cell-md-6 cell-lg-3">
    2. <div class="thumbnail-classic unit unit-sm-horizontal unit-md-vertical">
    3. <div class="thumbnail-classic-caption unit-body">
    4. <h6 class="thumbnail-classic-title"><perch:content id="title" type="text" label="Location title" required></h6>
    5. <hr class="divider divider-default divider-sm">
    6. <p class="thumbnail-classic-text"><perch:content id="sectionLeader" type="text" label="Section leader text"></p>
    7. </div>
    8. </div>
    9. </div>

    This results in neither template displaying on the location page?