EllisLab text mark
Advanced Search
1 of 16
1
   
Custom Fields in {exp:weblog:entries /}
Posted: 19 September 2006 07:53 PM
Avatar
Joined: 2006-01-05
632 posts

&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.

File Attachments
ext.custom_fields_in_ee_tags_218.zip  (File Size: 3KB - Downloads: 1030)
 Signature 
 
Posted: 21 September 2006 09:41 AM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-15
573 posts

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?

 Signature 


:: Westeros :: Hippoi Athanatoi ::

Blackadder: “Baldrick, have you no idea what irony is?”   
Baldrick: “Yeah! It’s like goldy and bronzy, only it’s made of iron.”
Blackadder III, Amy and Amiability

 
Posted: 21 September 2006 10:02 AM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2006-01-05
632 posts

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.

 Signature 
 
Posted: 21 September 2006 10:26 AM   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-15
573 posts

Will give it a try. smile 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.

 Signature 


:: Westeros :: Hippoi Athanatoi ::

Blackadder: “Baldrick, have you no idea what irony is?”   
Baldrick: “Yeah! It’s like goldy and bronzy, only it’s made of iron.”
Blackadder III, Amy and Amiability

 
Posted: 21 September 2006 10:38 AM   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2006-01-05
632 posts

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.

 Signature 
 
Posted: 21 September 2006 10:45 AM   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-15
573 posts

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.

 Signature 


:: Westeros :: Hippoi Athanatoi ::

Blackadder: “Baldrick, have you no idea what irony is?”   
Baldrick: “Yeah! It’s like goldy and bronzy, only it’s made of iron.”
Blackadder III, Amy and Amiability

 
Posted: 21 September 2006 11:55 AM   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2006-01-05
632 posts

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="/.+/"
 Signature 
 
Posted: 21 September 2006 11:59 AM   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2006-01-05
632 posts

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.

 Signature 
 
Posted: 21 September 2006 03:28 PM   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-15
573 posts

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.

 Signature 


:: Westeros :: Hippoi Athanatoi ::

Blackadder: “Baldrick, have you no idea what irony is?”   
Baldrick: “Yeah! It’s like goldy and bronzy, only it’s made of iron.”
Blackadder III, Amy and Amiability

 
Posted: 21 September 2006 03:44 PM   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2006-01-05
632 posts

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

 Signature 
 
Posted: 21 September 2006 03:57 PM   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-15
573 posts

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:

    {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}<a href=“http://www.westeros.org/Citadel/Heraldry/Entry/{entry_id}/” target=“Heraldry”  return false”>{if {current_weblog_id}_book_status == “Dead”}}{/if} - {{current_weblog_id}_motto}</li> {/exp:weblog:entries}

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?

 Signature 


:: Westeros :: Hippoi Athanatoi ::

Blackadder: “Baldrick, have you no idea what irony is?”   
Baldrick: “Yeah! It’s like goldy and bronzy, only it’s made of iron.”
Blackadder III, Amy and Amiability

 
Posted: 21 September 2006 04:23 PM   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2006-01-05
632 posts

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.

 Signature 
 
Posted: 21 September 2006 05:04 PM   [ # 12 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-15
573 posts

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).

 Signature 


:: Westeros :: Hippoi Athanatoi ::

Blackadder: “Baldrick, have you no idea what irony is?”   
Baldrick: “Yeah! It’s like goldy and bronzy, only it’s made of iron.”
Blackadder III, Amy and Amiability

 
Posted: 21 September 2006 09:38 PM   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2006-01-05
632 posts

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

 Signature 
 
Posted: 22 September 2006 07:11 AM   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-15
573 posts

Its a plain old text field, no unusual content.

 Signature 


:: Westeros :: Hippoi Athanatoi ::

Blackadder: “Baldrick, have you no idea what irony is?”   
Baldrick: “Yeah! It’s like goldy and bronzy, only it’s made of iron.”
Blackadder III, Amy and Amiability

 
Posted: 22 September 2006 07:49 AM   [ # 15 ]   [ Rating: 0 ]
Joined: 2005-01-05
115 posts

Hi, not helping much but I’ve just tried the extension and again it doesn’t seem to be working…

I was hoping the below code would only display entries where ‘casestudy-thumb’ contained content.  stripping the limit and orderby parameters, disabling other extensions doesn’t help either.

<dl>
{exp:weblog:entries weblog="studies" limit="1" orderby="random" casestudy-thumb="/.+/"}
<dt><a href="{comment_url_title_auto_path}">{title}</a></dt>
<
dt class="image"><a href="{comment_url_title_auto_path}">{casestudy-thumb}</a></dt>
<
dd>
<
p>
{exp:html_strip}{exp:char_limit total="125"}
{casestudy
-intro}
{
/exp:char_limit}{/exp:html_strip}
</p>
<
p>
<
a href="{comment_url_title_auto_path}">Read the full Case Study...</a>
</
p>
</
dd>
{/exp:weblog:entries}
</dl
 
1 of 16
1