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.

how to "filter" categories in a tabbed setup?

August 11, 2011 11:14pm

Subscribe [1]
  • #1 / Aug 11, 2011 11:14pm

    manuqc

    115 posts

    Hello,

    I am finishing to build a site for a client, but I just got a last minute request… (yeah there is always one of those!) I ll explain myself better.

    One of the modules in the website is a photo section. This section has a “thumbnail slider” and a lightbox pop up displaying flickr slideshows. So far Ive got everything to work seamlessly with expression engine even the flickr output…

    Now I ve got requested to add a “filter” for the thumnails, so that it only displays thumbnails of “x”,“y” or “z” category at a time. I haven’t setup categories originally for this, as I wasn’t needing them.

    I am not sure what would be a good way to “load” (filter”) the thumbnails using categories, as most examples I ve seen load categories on a separated page not on the same page as I’ll need them (but this is probably because I am not aware of a proper way to achieve this)

    I now created two categories for testing, “news” and “video clip”.

    here is an example of what I want to achieve (note that the broken layout on this example is due to testing purposes 😉

    http://sofia-marikh.com/index.php/main/tabs2


    So far this is my code, I will like your advice on this as I haven’t worked a lot with categories, hopefully you can help me out as I am a bit on time to expand further on my own, this example is working except the filter.


    Here is the current code for the embedded “photos” section:

     


    Thanks in advanced for your time, I do appreciate your help.

    Regards,


    Manu

  • #2 / Aug 12, 2011 10:29am

    Kevin Smith

    4784 posts

    Hi Manu,

    It’s definitely possible to filter Channel Entries by category. Actually, the channel entries tag looks in the URL segments for clues on this sort of thing. For example, if it sees “C1” in the URL, it will only output channel entries that are in the category with ID #1.

    I’m not sure which photos you have loaded into the two categories, but you should be able to see the differences in the channel entries displayed between these two links:

    http://sofia-marikh.com/index.php/main/tabs2/C1
    http://sofia-marikh.com/index.php/main/tabs2/C2

    You’re so close, you almost had your code spitting out the right links! Notice the example in the documentation on the Channel Categories tag. The only thing you should have to change is in between the Channel Categories tag, where you see this:

    <td><a href="http://">{category_name}</a></td>

    Change it to this:

    <td><a href="http://{path=main/tabs2}">{category_name}</a></td>

    Does that help?

  • #3 / Aug 12, 2011 1:56pm

    manuqc

    115 posts

    Hello Kevin,

    Thanks for your answer. Good to know I wasnt too far. I actually put your codeline, and got the example “tabs2” to work displaying categories.

    tabs example working

    But once I try to embed this section on the main page, I am getting an error from the browser everytime I try clicking on a category saying, “continue script” (in which case if I click it will crash the browser) or “stop script”.

    This it the test page with the embeded “photos section”


    test page with embeded photos section

    this embeded “photos” section has a difference with the “tabs2” page above. Is that I changed “{path='main/tabs2'}” to “{path='main/test-photos-all'}” as its now included on the “test-photos-all” page, and this is when its not working.

    Hope you can help me out to solve this, I do appreciate your help!

    Regards,


    Manu

    Ps: Also I created a third test category “shows” I only did one entry, but I am getting the entry repeated several times. When I add 2 entries this behavior dissapears, wondering why? Thanks!

  • #4 / Aug 12, 2011 5:39pm

    Kevin Smith

    4784 posts

    Glad my suggestion got you pointed in the right direction!

    Does the repeating entry go away if you replace

    {exp:channel:entries channel="photos" dynamic="no" limit="13" category="{segment_2}"}

    with

    {exp:channel:entries channel="photos" limit="13"}

    ?

    The error from your browser asking you whether or not you want to continue loading the page or to stop the script means you need to do some work on your HTML and JavaScript. That’s beyond what I’m able to help you with, but I can move this thread over to Community Help where others in the community can toss in and help you figure this out. Would that work for you?

  • #5 / Aug 12, 2011 5:42pm

    manuqc

    115 posts

    Hello Kevin,

    Thanks for your answer, yes that will be awesome.
    I will take a look tonight. Hopefully someone can help me out in the mean time,

    Regards.


    -Manu

  • #6 / Aug 12, 2011 6:27pm

    Kevin Smith

    4784 posts

    No problem, Manu. I’ve got you over in the Community Help forum now. Best of luck!

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

ExpressionEngine News!

#eecms, #events, #releases