1 of 13
1
Custom Fields in {exp:weblog:entries /}
Posted: 19 September 2006 04:53 PM   [ Ignore ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

&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: 458)
 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 21 September 2006 06:41 AM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1505
Joined  05-15-2004

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

Profile
 
 
Posted: 21 September 2006 07:02 AM   [ Ignore ]   [ # 2 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

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 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 21 September 2006 07:26 AM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1505
Joined  05-15-2004

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

Profile
 
 
Posted: 21 September 2006 07:38 AM   [ Ignore ]   [ # 4 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

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 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 21 September 2006 07:45 AM   [ Ignore ]   [ # 5 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1505
Joined  05-15-2004

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

Profile
 
 
Posted: 21 September 2006 08:55 AM   [ Ignore ]   [ # 6 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

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 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 21 September 2006 08:59 AM   [ Ignore ]   [ # 7 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

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 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 21 September 2006 12:28 PM   [ Ignore ]   [ # 8 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1505
Joined  05-15-2004

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

Profile
 
 
Posted: 21 September 2006 12:44 PM   [ Ignore ]   [ # 9 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

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 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 21 September 2006 12:57 PM   [ Ignore ]   [ # 10 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1505
Joined  05-15-2004

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}<a href=“http://www.westeros.org/Citadel/Heraldry/Entry/{entry_id}/” target=“Heraldry”>{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?

 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

Profile
 
 
Posted: 21 September 2006 01:23 PM   [ Ignore ]   [ # 11 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

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 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 21 September 2006 02:04 PM   [ Ignore ]   [ # 12 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1505
Joined  05-15-2004

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

Profile
 
 
Posted: 21 September 2006 06:38 PM   [ Ignore ]   [ # 13 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

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

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 22 September 2006 04:11 AM   [ Ignore ]   [ # 14 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1505
Joined  05-15-2004

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

Profile
 
 
Posted: 22 September 2006 04:49 AM   [ Ignore ]   [ # 15 ]  
Research Assistant
RankRankRank
Total Posts:  547
Joined  01-05-2005

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>

 Signature 

Celebrating again soon.

Profile
 
 
Posted: 22 September 2006 05:22 AM   [ Ignore ]   [ # 16 ]  
Research Assistant
RankRankRank
Total Posts:  547
Joined  01-05-2005

OK I just tried to do things slightly differently but still got odd results.

I created a new custom field called ‘casestudy-featured’ which was a dropdown list with values Yes and No.

I then set one entry to ‘Yes’ and used the code below.

{exp:weblog:entries weblog="studies" casestudy-featured="/Yes/"}
...
{/exp:weblog:entries}
</dl>

Doing that still displays all the entries.

Then tried limiting.

{exp:weblog:entries weblog="studies" limit="1" casestudy-featured="/Yes/"}
...
{/exp:weblog:entries}

Only displays one entry but it’s not an entry where casestudy-featured is set to Yes.

Then checked to see if it was anything to do with the hyphen in the name.

{exp:weblog:entries weblog="studies" casestudyfeatured="/Yes/"}
...
{/exp:weblog:entries}

Without the hyphen (and without limiting entries) it works!  If I do limit the entries though it doesn’t display anything.

Hope some of that helps you debug smile

 Signature 

Celebrating again soon.

Profile
 
 
Posted: 22 September 2006 07:22 AM   [ Ignore ]   [ # 17 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

I’ll have a chance to look into this later today, but that is helpful, and I think the problem is that it’s not recognizing custom fields with non-alpha-numeric characters (ie: underscores and hyphens).  I’ll look into it, fix it and let you know.

Mark

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
Posted: 22 September 2006 08:15 AM   [ Ignore ]   [ # 18 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1183
Joined  01-05-2006

Alright, I made a few changes and I got it working using the following field names:

* 24_body
* my-body
* my_body

You can download the most up to date version (1.0.2) above.  Let me know if it helps.  I’ve also updated the multi drop-down list extension in case it isn’t playing nice with this extension.  you can download that here: http://expressionengine.com/forums/viewthread/38370/

 Signature 

================================================
    Mark Huot
    http://markhuot.com
================================================

Profile
 
 
   
1 of 13
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64535 Total Logged-in Users: 21
Total Topics: 81116 Total Anonymous Users: 18
Total Replies: 436448 Total Guests: 192
Total Posts: 517564    
Members ( View Memberlist )
Newest Members:  marlusbluespotmusicvolandspinhirnetheminiokostiamasterjeMBossbchaleyalvonsius