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.

Order entries by category id

May 15, 2012 8:47am

Subscribe [2]
  • #1 / May 15, 2012 8:47am

    Scotta

    136 posts

    Hello,

    I would like output all the entries from a channel, but one category after another.

    i.e :

    cat 1 - entry 1
    cat 1 - entry 2
    cat 2 - entry 1
    cat 2 - entry 2
    cat 2 - entry 3

    etc..

    Is there any way to do that without performing several channel entries loops ?

    Cheers,
    L.

  • #2 / May 16, 2012 9:28pm

    John St-Amand

    865 posts

    Category Archives would get you there, but only if all you need is the title of the entry - custom fields are unavailable in that particular loop.

  • #3 / May 17, 2012 12:48am

    Scotta

    136 posts

    Hello John,

    Alas I need the custom fields.
    I hope there is another solution.

    Cheers.

  • #4 / May 17, 2012 6:51am

    John St-Amand

    865 posts

    Not natively without going with an entries loop inside each category (this can be dynamic - there’s an example in the comments in the docs).  If you’re using various caching options, it’s not too bad, unless you have a large number of categories.  To do it more efficiently, I think you’d have to use PHP in your templates.  I know it’s a question that has been asked in the forums before, so if you’re lucky there may be a code example in the responses somewhere, if you’re able to find the right post.

  • #5 / May 18, 2012 2:43am

    Scotta

    136 posts

    Ok, I’ll do it with jQuery on front end…

  • #6 / May 18, 2012 7:00am

    Bhashkar Yadav

    727 posts

    Hi Laureent,

    I think, it’s possible by creating a custom field that hold the category id assigned to that entry.

    As in EE more than one categories can be assigned to an entry but here in your case, it seems that channel entries will have only one category so the custom field will contain a number (category id) and this custom field name can be passed into orderby parameter of channel tag.

    In this way your requirement can be fulfilled. you can think that it can be a manually process of updating checked category id into custom field. But it can be done with extension hook automatically.


    I hope it would help you.


    Best Regards,

  • #7 / May 18, 2012 7:13am

    Scotta

    136 posts

    Hello Bhashkar,

    The work is done already, but your idea looks interesting, I’ll keep that in mind.

    Cheers

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

ExpressionEngine News!

#eecms, #events, #releases