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.

Limit to one entry by custom field

November 17, 2011 11:08am

Subscribe [4]
  • #1 / Nov 17, 2011 11:08am

    cognitiv

    2 posts

    This seems to be an easy thing, but I cannot find an example of it so I will try and ask here. I am building a car site that pulls from one channel with many custom fields. One of those custom fields is model of the car. A simple channel query will list every instance of the cars model, and I would like for it to only pull it once and ignore the other entries with the same name. For example, say we have a Toyota Corolla and three different entries with slightly different data, it will list the Corolla three times and I just wish it would do it once. I hope this makes sense…

  • #2 / Nov 17, 2011 12:58pm

    You can add limit=“1” to your channel entries tag. Depending on your template/URL structure you may also need to toy with dynamic=“no” and pass in the url_title parameter with a segment value. Everything you need should be available at http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html.

  • #3 / Nov 17, 2011 9:27pm

    Sean C. Smith

    3818 posts

    cognitiv,

    As caddisint suggests adding limit=“1” to your channel entries tag should do what you want. Please let me know if there is anything else.

    Sean

  • #4 / Nov 28, 2011 9:51am

    cognitiv

    2 posts

    Maybe an example page? This would be what I’m working on:

    http://redacted

    On this page, this is how it is grabbing the entries:

    {exp:channel:entries channel="{segment_1}” category=”{segment_2_category_id}” orderby=“title” sort=“asc” limit=“500”}

    This is using the Seg2Cat extension, but everything else if normal. Now that I have those results, I’d like to limit it by displaying only one model of each car instead of the 20 or so that are showing up. I’m thinking GROUP BY in terms of MySQL. Not sure if this is any clearer…

  • #5 / Nov 28, 2011 1:55pm

    cognitiv

    2 posts

    Nevermind, forgot about the query module. Just used it instead. Thanks!

  • #6 / Nov 30, 2011 4:21pm

    Kevin Smith

    4784 posts

    Glad you’ve got a working solution, cognitiv! Let us know if there’s anything else we can do to help.

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

ExpressionEngine News!

#eecms, #events, #releases