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.

group channel entries by custom field + generate headers

June 17, 2010 12:08am

Subscribe [2]
  • #1 / Jun 17, 2010 12:08am

    Michael Rog

    179 posts

    The channel module makes it easy to SORT by a custom field, but I need to GROUP entries by a custom field and then generate headers (similar {date_header}) to appear before each group.

    Is there any way to twist native features to do this, or do I need to resort to custom SQL?

  • #2 / Jun 17, 2010 1:36am

    ender's avatar

    ender

    1644 posts

    You can use the string plugin to do this.

    I posted a code sample for doing this within the rows of a FF Matrix custom field here but the strategy will work just as well to do something similar with a set of entries inside a weblog:entries tag.

  • #3 / Jun 17, 2010 11:58am

    Michael Rog

    179 posts

    Indeed, that is exactly the strategy I need!

    (http://ellislab.com/forums/viewthread/157893/)

    Your String Plugin looks like a great addon. Curiously, though, is there any advantage to using the plugin over straight PHP conditionals (parsed on output)?

  • #4 / Jun 17, 2010 12:27pm

    ender's avatar

    ender

    1644 posts

    a couple minor advantages in some situations based on EE’s strange parse order (where output PHP would be executed from top to bottom after the EE parser was done with the template), but no if you are comfortable with PHP you can easily use that in this instance.

  • #5 / Jul 29, 2015 3:41pm

    tacuster

    10 posts

    How might the string plugin be used without a Matrix field to perform the same task? I simply have a channel of stores that I’d like to group by state. State is one of the custom fields in the channel. I’d like to use that same state field as header for each group of stores.

    IDAHO

    Store #1
    Address
    Phone

    Store #33
    Address
    Phone

    CALIFORNIA

    Store #9
    Address
    Phone

    Store #56
    Address
    Phone

    etc…

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

ExpressionEngine News!

#eecms, #events, #releases