ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

detecting entry list type at page level

August 03, 2011 4:28pm

Subscribe [3]
  • #1 / Aug 03, 2011 4:28pm

    david mantripp

    59 posts

    Hi -

    Does anybody have any suggestions on how I can resolve this:

    I would like to change the layout and contents of the sidebar on my index template depending on whether it is displaying a a category based or full entry list. Initially I though I could use “if category” or “if not_category” but then I realised these apply at entry level, not page level, and only within a channel:entries tag.

    There must be a way to do this at page level ....

    Thanks
    David

  • #2 / Aug 04, 2011 10:51am

    Kevin Smith

    4784 posts

    Hi David,

    I’ve moved this over to the Community Help forum since it’s more of a question about how to best accomplish something. Could you post back the template code you’re using, including the way you’d like for this to work (even if it’s not technically correct)?

  • #3 / Aug 04, 2011 3:37pm

    david mantripp

    59 posts

    Hi Kevin,

    Well actually I’ve found a solution. It isn’t elegant, to my mind, but it works:

    {if segment_2 == "" }
      <h2 class=“sidebarTitle”>{my_channel_name}: Home</h2>
      {sng_sidebar_recent_entries}
      {sng_sidebar_search}
      {sng_sidebar_blogroll}
      {sng_sidebar_monthly_archives}
      {sng_sidebar_syndicate}

    {if:else}
      {sng_sidebar_category_info}
      {sng_sidebar_search}
      {sng_sidebar_categories_archive}
      {sng_sidebar_syndicate}
    {/if}

    If there’s a better way of doing this I’d love to hear of it!

    David

  • #4 / Aug 04, 2011 8:45pm

    the3mus1can

    426 posts

    You could try Sherlock: https://github.com/themusicman/Sherlock.

    I need to document it better, but it gives you what you are looking for.  It makes some assumptions about your url structure, but those assumptions can be overridden. Sample usage:

    {exp:sherlock:page_type}
        {if is_pagination} 
            There are a lot of these.
        {/if} 
        {if is_pagination && is_category}
            There are a lot of these to filter.
        {/if} 
        {if is_entry}
           Something with the entry here.
        {/if}
        {if page_type == 'category'} 
            Lets filter these entries a little.
        {/if}
    {/exp:sherlock:page_type}


    All of the conditionals come with the negative to:

    {exp:sherlock:page_type}
        {if is_not_pagination} 
            There are a lot of these.
        {/if} 
        {if is_not_pagination && is_not_category}
            There are a lot of these to filter.
        {/if} 
        {if is_not_entry}
           Something with the entry here.
        {/if}
    {/exp:sherlock:page_type}
  • #5 / Aug 05, 2011 7:51am

    david mantripp

    59 posts

    Sounds like it’s just what I need. I’ll give it a go, thanks.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases