2

I have a landing page which is to show all of the current members of an academic group. This group is to exclude alumni. The memberships of the various groups are categories, so I need to exclude this one particular category. When I try the following code to exclude alumni (category 4), the rest of the category filtering no longer works (i.e. when you click on a group to see the members, all people are listed in every category, instead of being filtered properly). The filtering works once I remove category="not 4" from the channel entries tag, but then the list shows all of the alumni, which is no good. The following is the code for the landing page, which is intended to show all memberships except alumni:

{exp:stash:append name="content"}
<p><strong>Please select a group to see its members: 
   {exp:channel:categories category_group="1" show="not 4" channel="people" show_empty="no" style="linear" backspace="8"}
   <a href="{path='people/index'}" >&nbsp;{category_name}</a>&nbsp; |{/exp:channel:categories}</strong></p>
        <br>
{/exp:stash:append}

{exp:channel:category_heading channel="people" show_empty="no"}
  {exp:stash:append name="content"}
  <h2>{category_name}</h2>
  {if category_description}<br /><h4>{category_description}</h4>{/if}
  {/exp:stash:append}      
{/exp:channel:category_heading}


  {exp:stash:append name="content"}
  <div id="main" role="main">
  <ul id="tiles">
 {exp:channel:entries channel="people" status="open" orderby="title" sort="asc" show-expired="no" limit="200" show_future_entries="no" category="not 4"} 

  <!-- grid blocks -->
   <li class="{if "{segment_3}" == "phd_students"}phd{/if}{if "{segment_3}" == "researchers"}researchers{/if}{if "{segment_3}" == "support"}support{/if}{if "{segment_3}" == "masters"}masters{/if}"><img src="{people_img}" width="100" class="biopic"><h3>{people_name}</h3><p>{people_bio}</p>{if people_email}<p><a href="mailto:{people_email}">contact</a></p>{/if}</li>
  <!-- End grid blocks -->

{/exp:channel:entries}
  </ul>
  </div>
  {/exp:stash:append}
  • What's on the people/index template? – erwinheiser Aug 29 '13 at 10:04
  • The above code is on the people/index page. – Alissa J. Robinson Aug 29 '13 at 11:04
0

Ive looked at docs and cant immediately see why its not working.

Change this code (and all similar): {if "{segment_3}" == "phd_students"}phd{/if} - you turned a simple conditional into an advanced conditional.

To this {if segment_3 == "phd_students"}phd{/if} - back to simple conditional

Also, change show-expired to show_expired

Read this too parse order. Keep it handy.

Then, start by simplifying the page. Put the categories tag only in a template and test until you get the required output using 'not'.

Then use stash set_list to cache the output for 1440 minutes.

Dont stash markup, just the variables you want to store.

Read the stash docs carefully, its a great tool when used wisely.

Go to the db tables find exp_stash, browse and check to see your stored values are all there.

Repeat for remaining tags until you have created your stash caches.

Finally, use get_list to output your lists in your markup.

With stash, parse order becomes very important. Following the above steps will help you learn. Also read the debugger at bottom of template to check the parse order if you are having issues.

Edit: an example of a stash set_list for categories saved into exp_stash. This can be reused anywhere in our site using get_list.

cat2_name|=|Aged Care|&|cat2_url|=|aged-care|&|cat2_count|=|1|+|cat2_name|=|Bed & Breakfast|&|cat2_url|=|bed-breakfast|&|cat2_count|=|1|+|cat2_name|=|Caravan & Campgrounds|&|cat2_url|=|caravan-campgrounds|&|cat2_count|=|1|+|cat2_name|=|Holiday Resorts|&|cat2_url|=|holiday-resorts|&|cat2_count|=|1

| improve this answer | |
  • Also, change show-expired to show_expired – Lloyd Hill Aug 29 '13 at 11:43
  • solid advice. I'd also look into using switchee devot-ee.com/add-ons/switchee to remove the 3 if statements testing for segment_3 – erwinheiser Aug 29 '13 at 17:39
  • No, you dont need to use switchee here. Those if + segment conditions are all simple conditionals. Thats good - parsed early. No need to add switchee here, in fact might cause you more parse issues given that its nested inside multiple tags. – Lloyd Hill Aug 29 '13 at 17:50
  • Also, why cache you ask? This is a landing page, you say. Once cached, the page will load MUCH faster. When cache expires, next person to hit the page will trigger all the tags and related queries and recreate your stash cache. – Lloyd Hill Aug 29 '13 at 17:53
  • Sample cache dump added – Lloyd Hill Aug 29 '13 at 18:01
0

It's now working! For the sake of closure, here's the final code:

    {exp:stash:append name="content" parse_conditionals="yes" parse_tags="yes" }
    <p><strong>
      Please select a group to see its members: 
      {exp:channel:categories category_group="1" channel="people" show="not 4" show_empty="no" style="linear" backspace="7"}<a href="{path='people/index'}">{category_name}</a>&nbsp;|&nbsp;{/exp:channel:categories}
    </strong></p><br>

    <div id="main" role="main">
      <ul id="tiles">

        {if segment_2 == 'cat'}
          {exp:channel:entries channel="people" orderby="title" sort="asc" limit="200" disable="member_data|pagination"}
             <li class="{if segment_3 == 'phd_students'}phd{/if}{if segment_3 == 'researchers'}researchers{/if}{if segment_3 == 'support'}support{/if}{if segment_3 == 'masters'}masters{/if}">
                <img src="{people_img}" width="100" class="biopic">
                <h3>{people_name}</h3>
                <p>{people_bio}</p>
                {if people_email}<p>{encode='{people_email}' title='contact'}"></p>{/if}
             </li>
          {/exp:channel:entries}
        {/if}

        {if segment_2 != 'cat'}
          {exp:channel:entries channel="people" orderby="title" sort="asc" limit="200" disable="member_data|pagination" category="not 4"}
              <li class="{if segment_3 == 'phd_students'}phd{/if}{if segment_3 == 'researchers'}researchers{/if}{if segment_3 == 'support'}support{/if}{if segment_3 == 'masters'}masters{/if}">
                <img src="{people_img}" width="100" class="biopic">
                <h3>{people_name}</h3>
                <p>{people_bio}</p>
                {if people_email}<p>{encode='{people_email}' title='contact'}"></p>{/if}
             </li>
          {/exp:channel:entries}
        {/if}

     </ul>
   </div><br>
{/exp:stash:append}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.