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 entries to custom field value

June 25, 2007 7:14pm

Subscribe [3]
  • #1 / Jun 25, 2007 7:14pm

    pirco

    218 posts

    this might be easy (but a solution evades me):

    I have a template with pagination and entries that have a custom field that can be set to either yes or no. (I prefer this to a custom status for some reasons).

    I would like to filter my entries depending on the value of field.

    right now, I’m using

    {exp:weblog:entries weblog="{my_weblog}" limit="10"}
    {if type=="yes"}
    <!-- only show entries of custom "type" field value==yes -->
    {/if}
    {/exp:weblog:entries}

    so far, this works great, except that pagination shows up even if there are only 9 or less entries of custom “type” field value “yes” (because the total number of entries is > 10).

    how can I hide the pagination?

    thanks,
    pirco

  • #2 / Jun 25, 2007 10:38pm

    Sue Crocker

    26054 posts

    Which version/build of EE?

    Order by Parameter

  • #3 / Jun 26, 2007 12:40am

    pirco

    218 posts

    it’s the latest and greatest (as of today) but, oh dear, I saw my mistake…
    I had the {paginate} tags surrounded by a second set of {weblog:entries} tag - I wanted to display the pagination outside of the original loop.

    sorry for the misunderstanding but many thanks for your response!

  • #4 / Jun 26, 2007 12:52am

    pirco

    218 posts

    ok. now I’m really sorry… That mistake wasn’t the culprit after all. I guess it’s a question of logic (and maybe I do have to rethink that). the thing is that paging still gets added, even if the page only shows 3 entries (that match my custom field called “type” = yes).
    so, all in all, I have 14 entries for this given category. 3 have a custom field “type” set to “yes”.
    if I display that template, then it shows the three entries but since the {weblog:entries} loop counts all 14 (and sets the limit for paging to 10), the pagination shows. I hope this makes sense. check the code above again, if you will, and let me know if you have a better solution.
    I wish there was a parameter like

    limit_by_custom_field_name="type" limit_by_custom_field_value="true"

    😊

  • #5 / Jun 26, 2007 5:37am

    Ingmar

    29245 posts

    I’d simply use Mark Huot’s extension.

  • #6 / Jun 26, 2007 12:01pm

    Robin Sowell

    13255 posts

    Yep- you’d want to use the extension or just use the query module.  OR switch them to categories, if that seems appropriate.  There isn’t a native way to do it with the weblog tag- not without jamming pagination.

  • #7 / Jun 26, 2007 12:40pm

    pirco

    218 posts

    this is great. i thank the both of you.

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

ExpressionEngine News!

#eecms, #events, #releases