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.

Get entries from categorie

March 23, 2009 7:15am

Subscribe [3]
  • #1 / Mar 23, 2009 7:15am

    Hi,

    I have a question.

    Currently there are around 20 entries in multiple weblogs, these entries all have an appropriate categorie assigned and now i want to display all the entries in one categorie.

    The question is, HOW?

    I tried everything, read through all the docs and the forum, but didn’t find anything which could help me out.

    Hope anyone can help.

  • #2 / Mar 23, 2009 8:06am

    Steve Abraham

    149 posts

    Hi Kevin,

    You should be able to do this quite simply using the “category” parameter, i.e.

    {exp:weblog:entries  weblog="blog1|blog2|blog3"  category="20" }
    *SNIP*
    {/exp:weblog:entries}

    Unless I’ve misunderstood your problem.

    Cheers,
    Steve.

  • #3 / Mar 23, 2009 8:07am

    well, you’re right on that, but how do I convert the categorie name to categorie ID?

  • #4 / Mar 23, 2009 8:11am

    Steve Abraham

    149 posts

    Hi Kevin,

    Unfortunately because of a number of issues with using names you have to use the ID… Ellis explain it better than I can:

    Categories are specified by ID number (the ID number of each category is displayed in the Control Panel). The reason we use the ID is because categories can be called anything (with spaces, quotes, etc.), and also renamed. It would be much more difficult to have to update the tag parameters every time you updated a category name. Further, you can have multiple categories with the same name either in different Category Groups or in different parts of the hierarchy within the same Category Group.

    Are you stuck with having to use the name (rather than the ID)?

    S.

  • #5 / Mar 23, 2009 8:13am

    Yes, as a matter of fact i do.

    But, I could try to hard code the relation between id and title.

  • #6 / Mar 23, 2009 8:19am

    Steve Abraham

    149 posts

    I have had to do that myself in the past in certain circumstances - the problem then comes if you have to change a category name, but that may not be an issue in your case.

    S.

  • #7 / Mar 23, 2009 8:22am

    Well, unfortunately it is.

    Did you solved this problem with PHP or just plain EE tags?

  • #8 / Mar 23, 2009 8:32am

    Steve Abraham

    149 posts

    On the one project that this came up with I actually ended up altering the URL to include both the name and ID of the category - messy, but it worked in that particular case.

    Basically I ended up with:

    http://www.example.com/cat1/12/cat2/13/cat4/14

    I could then use segment_1, 3 and 5 when I needed to refer to the name, and segment_2, 4 and 6 when I needed the ID.

    Less than ideal perhaps, but it worked OK in my case.

    Perhaps someone else can suggest a better solution for you - apologies I wasn’t much help. 😊

    S.

  • #9 / Mar 23, 2009 8:41am

    Thanks for your help, though it’s not perfect.

    I am thinking of hardcoding the relationships between id’s and their categories.
    Put them in a seperate template, so it stays at least kind of noob-friendly to edit things on the website.

    Your example ain’t very search engine friendly as well, which is kind of the reason why we bought EE in the first place.

    Well, I really hope someone has a better idea…

  • #10 / Mar 23, 2009 8:43am

    Steve Abraham

    149 posts

    I understand.

    The reason I went for my approach was because the example above is better for SEO than simply having the ID.

    I’ll also be interested to see if someone has an alternative solution.

  • #11 / Mar 23, 2009 9:32am

    Ok, I think i am having a little conflict here:

    
    
    

    where this works absolutely fine:

    
    
    

    I think this means conflict, but i don’t know where, what and, most important, why…

  • #12 / Mar 23, 2009 9:35am

    Steve Abraham

    149 posts

    Yep - you can’t use a weblog:entries tag within a weblog:entries tag, that’s why you’ll be having problems with the first example.

  • #13 / Mar 23, 2009 9:38am

    Yep - you can’t use a weblog:entries tag within a weblog:entries tag, that’s why you’ll be having problems with the first example.

    Okay, I changed that, and now, the right part shows, but the left part doesn’t!
    So, I keep calling it a conflict 😛.

  • #14 / Mar 23, 2009 9:41am

    Steve Abraham

    149 posts

    Show us the code you have now and I’ll have another look. 😉

  • #15 / Mar 23, 2009 9:44am

    
    
    

    There you go.

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

ExpressionEngine News!

#eecms, #events, #releases