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

Custom Fields in {exp:weblog:entries /}

Development and Programming

Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

&otOk;. This extension allows you to limit your weblog:entries calls by a custom field. So a theoretical call could look like any of these:

{exp:weblog:entries custom_field="pattern"}{title}{/exp:weblog:entries}
  {!-- any entry with 'pattern' in the custom field --}

{exp:weblog:entries custom_field=;>100239320"}{title}{/exp:weblog:entries}
  {!-- any entry where custom_field is greater than 100239320 --}

{exp:weblog:entries custom_field="<100239320"}{title}{/exp:weblog:entries}
  {!-- any entry where custom_field is less than 100239320 --}

{exp:weblog:entries custom_field="=pattern"}{title}{/exp:weblog:entries}
  {!-- any entry where custom_field exactly matches "pattern" --}

{exp:weblog:entries custom_field="!pattern"}{title}{/exp:weblog:entries}
  {!-- any entry where "pattern" is not in custom_field --}

{exp:weblog:entries custom_field="!=pattern"}{title}{/exp:weblog:entries}
  {!-- any entry where custom field does not exactly match "pattern" --}

Let me know if this helps/breaks everything it’s definitely in alpha development.

       
Linda A's avatar
Linda A
647 posts
18 years ago
Linda A's avatar Linda A

I’ve got a fairly resource-intensive template which, among other things, pulls in only those entries for a specific weblog where a certain custom field has been filled out. So it doesn’t check for a specific string, it just checks whether the field is filled out. Can I use this extension for that too, and would it be less resource-intensive than the conditional I am currently using?

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

It may be faster for you because the processing happens before the templating engine is run. Please do give it a try and let me know how it works. If you have any trouble with implementation let me know and I’ll lend a hand. I’d love to see how this extension really handles itself in the wild.

       
Linda A's avatar
Linda A
647 posts
18 years ago
Linda A's avatar Linda A

Will give it a try. 😊 I am not quite sure, however, how I would construct the pattern to tell it to look for the specific custom field only when said custom field has any content. I tried adding custom_field=”motto” to my weblog:entries tag, but the result is that all entries are returned, not just those where that custom_field exists.

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

the syntax should be field_name=”value” so if I had a field named description I could search for all descriptions about dogs like so {exp:weblog:entries description="/dogs/"} or if I wanted to see where description was not empty you could try {exp:weblog:entries description="/^$/"}. I’m not sure if that will work, but give it a try. I’ll test it out later today and get back to you.

       
Linda A's avatar
Linda A
647 posts
18 years ago
Linda A's avatar Linda A

Ahh, okay. Misunderstood the syntax. However, using “/^$/” to check for not empty does not, unfortunately, seem to work. It results in no entries at all being returned.

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

hum..well that’s because i was dumb. searching for /^$/ would return only empty descriptions. you would actually need to search for /.+/ which would return all entries with content in them.

{exp:weblog:entries description="/.+/"}
       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

I have updated the extension to play nice with other extensions using the same hook, so you’ll need to update if you’re running multiple extensions that alter the template output. See the first post to get the most up to date extension.

       
Linda A's avatar
Linda A
647 posts
18 years ago
Linda A's avatar Linda A

I grabbed the new version (and disabled and reenabled the extension to make sure it was updated), and changed the tag to {exp:weblog:entries motto="/.+/"}, but this still ends up listing all the entries, not just those that actually have the motto custom field filled out.

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

maybe you could PM me the login to you EE install and I’ll take a look. As far as I can tell that should work. Do you have any other extensions installed? Is it listing all the entries in your system? Can you try limiting it to a specific weblog and see that does in fact change the returned entries? Thanks

       
Linda A's avatar
Linda A
647 posts
18 years ago
Linda A's avatar Linda A

Extensions:

Link Entry from the Control Panel to Your Site (v.1.0.3) Amazon pop-up search (v.1.0.0) Custom Fields in EE Tags (v.1.0.1) Multi Drop-down List (v.1.0.0) NoFocus (v.1.0.0) Trackback Expiration Extension (v.1.00)

I doubt they’re conflicting, but the actual tag I am using is fairly busy in itself, so it could very well be another conflict. Here’s what I am doing:

<ul> {exp:weblog:entries weblog="weblog24" 24_motto="/.+/" category="98" entry_id="not 445" limit="100" orderby="title" sort="asc" disable="member_data|pagination|trackbacks"} <li>{if {current_weblog_id}_book_status == “Dead”}{{/if}{title}{if {current_weblog_id}_seat} of {{current_weblog_id}_seat}{/if}{if {current_weblog_id}_book_status == “Dead”}}{/if} - {{current_weblog_id}_motto}</li> {/exp:weblog:entries} </ul>

Its supposed to pull all entries from the specific weblog and category that has a motto (field: 24_motto), but instead it pulls all the entries from the specific weblog and specific category. I suspect it may break because of those other limitations, perhaps?

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

try disabling the multi drop-down list. there may be a bug in v1.0.0. also try moving the 24_motto=”/.+/” to the end of the call like so:

{exp:weblog:entries weblog="weblog24" category="98" entry_id="not 445” limit="100" orderby="title" sort="asc" disable="member_data|pagination|trackbacks" 24_motto="/.+/"}

also make sure that 24_motto is the short name of your field. if it is you’re good, i’ve never used numbers in my short names like that, but that shouldn’t be causing the issue.

       
Linda A's avatar
Linda A
647 posts
18 years ago
Linda A's avatar Linda A

Double-checked the short name field, its correct. I use the number of the weblog in case I ever have two fields with the same name in different groups, and it works fine for everything else, so it shouldn’t be the issue.

I also disabled the multi drop-down and moved the check on the custom field to last in the entries tag, but no luck. I think I will try breaking the code out into a separate template, just to make sure its not failing due to any of the other code in there (its a very busy template even outside of that particular tag).

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

What is stored in that motto field? Is it a text field? A text area?

       
Linda A's avatar
Linda A
647 posts
18 years ago
Linda A's avatar Linda A

Its a plain old text field, no unusual content.

       
1 2 3 Last

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.