We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

if statement with a limit

Development and Programming

dmacli's avatar
dmacli
141 posts
17 years ago
dmacli's avatar dmacli

I want to display the first 10 entries that have a “rating” > 3, where rating is a custom field. Here is the code I used:

{exp:weblog:entries weblog="equipment"}
       {if rating > 3}{title}{/if}
{/exp:weblog:entries}

The problem I run into is that this code cycles through the first 10 entries and pulls out only those with a rating < 3. The end result is I end up with less than 10 entries on the page.

Is the only way to do what I want it do is to use some sort of php code that does an x+1 type thing? Or is there a better way I am missing?

If php is the only way then can someone help me with the code? I get the concept but I dont know how to execute it.

Many thanks!

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
17 years ago
Lisa Wess's avatar Lisa Wess

Have a look at this thread for an extension that can help with this[/url].

       
dmacli's avatar
dmacli
141 posts
17 years ago
dmacli's avatar dmacli

Thank you, but I am actually using this within the SolSpace Ratings Module. Any idea if this extension will have the same effect within the Ratings Entries Tag?

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
17 years ago
Lisa Wess's avatar Lisa Wess

I highly doubt it. I’m going to move this to the Modules forum; I’d also recommend posting over on Solspace.com’s forums for ideas on how best to handle this.

[Edit]: I haven’t used the ratings module, but if it stores the rating in a custom field then this extension will still work probably (as you’re still using the {exp:weblog:entries} tag - however there may be a cleaner and easier way to pull up only entries with a particular rating, using the module. So I’d recommend posting on the solspace forums to find out. =)

       
dmacli's avatar
dmacli
141 posts
17 years ago
dmacli's avatar dmacli

Thanks Lisa, this helps.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.