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.

View all items link - How to?

July 16, 2013 5:21am

Subscribe [4]
  • #1 / Jul 16, 2013 5:21am

    Wabi Sabi Press

    8 posts

    Hi there,

    This is a problem I have had for some time and just cannot work it out. I have searched all over the web, but just cannot find what I need.

    On my index page I section which has a profile of a designer, and a link which reads “View all items by designer”.

    I would like that link to take the user to a categories page that pulls in all the items that are tagged for that designer.

    I have a number of products that are tagged using a category tag. So the link on the homepage should pull in all the channel entries that are using the given category tag.

    However I also want that link to be dynamic, so that no matter what designer is displayed on the index page, it will always send the user to a page which pulls in all the correct channel entries.

    What I want to achieve is something similar to how a category link would work. Below is a simple example.

    INDEX PAGE:

    Cool Black Bags section

    LINK: “View all Black Bags”

    (Link goes to all items with a category of ‘Black’

    I hope this helps.

    Best regards

    Graham

  • #2 / Jul 16, 2013 8:17am

    T Adams

    36 posts

    I am relatively new to EE, so there might be a better way to achieve this, but here is how i achieved something similar.

    Create a template (i.e. one called designers)

    In the designers template index file add this code

    {exp:channel:entries 
     channel="YOUR DESIGNER ITEM ENTRIES" 
     category="{last_segment}"  
     dynamic="no"
    }
     your code goes here
    {/exp:channel:entries}

    and on your link on the index page should be like this

    {exp:channel:categories 
     channel="games" 
     style="linear"
    }
     <a href="http://{path=designers}{category_id}/"><li>{category_name}</li></a>
    {/exp:channel:categories}

    This should work… i think. As I mentioned, i am new(ish) to ee, so test this code first before using it on a live site.

    You might need to add a “/” between {path='designers'} and {category_id} depending on your setup

    T.

  • #3 / Jul 16, 2013 9:30am

    Wabi Sabi Press

    8 posts

    Hi T,

    Many thanks for your kind and quick reply.

    I updated my code as you said and it did work, but not as I would like. I added the category_group=“3” to the link (last part of the code) and this now pulls in a URL to the designer and takes me to the store page which lists all items with the category of a designer (category_group=“3”).

    However, the code also outputs a link for every designer, not the one I want. Please see code below and my further comments after the code.

    <section id="profile" class="designer tait"> <!-- start section -->
    <div class="container"> <!-- start .wrap -->
    <header>
    {exp:channel:entries channel="designer_profiles" orderby="date" category="{last_segment}" dynamic="no" sort="desc" limit="1"}
    <h1 class="title" id="new">
    <span>Latest</span>
    </h1>  
    </header>
    <div class="row">
    <div class="span4">
    <a href="http://">{designer_portrait}</a>
    </div> 
    <div class="span8 last">
    <h1>Designer Profile</h1> 
    <h2>{title}</h2>
    <p>{designer_summary}<br />
    {exp:channel:categories channel="store" category_group="3"  style="linear"}<br />
    <a href="http://{path=%27store/index%27}/{category_id}/" class="btn">View items by {title} >></a><br />
    {/exp:channel:categories} <br />
    {/exp:channel:entries}<br />
    </div><br />
    </div><br />
    </div><br />
    </section> <!-- end section -->

    The code about now outputs all designers. like so

    View items by {title} >>
    View items by {title} >>
    View items by {title} >>
    etc: etc:

    It should only output one desinger, which is the designer used in the top part of the code: channel=“designer_profiles”.

    Does this make sense?

  • #4 / Jul 16, 2013 10:48am

    T Adams

    36 posts

    From your code, am i right in assuming each designer is a category? I might be reading your code wrong.

  • #5 / Jul 16, 2013 10:56am

    travisb

    172 posts

    I think you can get the results you want by using category tag pair within your channel entries. Something like:

    {exp:channel:entries 
     channel="designer_profiles" 
     orderby="date" 
     category="{last_segment}" 
     dynamic="no" 
     sort="desc" 
     limit="1"
    }
    
     {categories show_group="3"}
            <a href="http://{path=store/{category_id}}">View items by {category_name}</a>
     {/categories}
     
    {/exp:channel:entries}

     

  • #6 / Jul 16, 2013 11:24am

    Wabi Sabi Press

    8 posts

    Hi Travis,

    Many thanks for your reply.

    Yes, thank you so much, that worked. The only part I needed to update was the link path:

    View items by {category_name}

    I also needed to make sure that the ‘store’ channel category was connected to the designer profiles channel and to make sure I checked the correct designer in the category list.

    The link then outputs only one designer and takes the user to the store template which displays all the items with that category.

    Once again, thank you so much for your kind help.

    Best regards

    Graham

  • #7 / Jul 16, 2013 5:48pm

    Boyink!

    5011 posts

    Probably a bit late to the party, but I posted an entry on Train-ee about working with categories:

    http://www.train-ee.com/courseware/free-tutorials/comments/working-with-categories/

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

ExpressionEngine News!

#eecms, #events, #releases