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

Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

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="http://{comment_url_title_auto_path}">{title}</a></dt>
<dt class="image"><a href="http://{comment_url_title_auto_path}">{casestudy-thumb}</a></dt>
<dd>

{exp:html_strip}{exp:char_limit total="125"}
{casestudy-intro}
{/exp:char_limit}{/exp:html_strip}


<a href="http://{comment_url_title_auto_path}">Read the full Case Study...</a>

</dd>
{/exp:weblog:entries}
</dl>
       
Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

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 😊

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

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

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

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://ellislab.com/forums/viewthread/38370/

       
Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

Hi Mark,

It now works with hyphens in the custom field name, but doesn’t display anything if I limit the results. Is this beyond the scope of the extension?

cheers, Jamie

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

That’s great it’s working with the hyphen, however it should work with the limit also. I will investigate.

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

Limit will not work based on the core functionality of EE. So I am planning on including my own limit field, something like ext_limit=”10” but for now I would (if you have the processing power) leave out the limit and put a conditional check in at the beginning to check the count: {if count < 10}{/if}

       
Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

Thanks Mark, I look forward to it.

Just as an aside, I don’t think using the {count} variable is going to work in the short term either for me. I have 12 entries, 2 of which have the custom field ‘casestudy-featured’ set to Yes.

When I run…

{exp:weblog:entries weblog="studies" casestudy-featured="Yes"}
{count}
{/exp:weblog:entries}

…the 2 entry’s count variables output as 7 and 10, not 1 and 2 as you’d expect.

I’m gonna go back to using {if casestudy-featured} for now. thanks for your help so far though 😊

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

Thanks for helping me debug a little further.

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

I’ve updated the extension again and instead of using limit=”10” you can use max=”10” and that should give you the entries you’re expecting. The only thing to be careful of is to make sure max=”10” comes before any of your custom field declarations.

       
Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

I’m sorry Mark. Using…

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

…lists all the entries.

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

try the max=”1” behind the custom field call, it should always be at the end, not the beginning. my mistake.

       
Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

sorry should have said. tried that…

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

…and it displays all the entries with casestudy-featured set to Yes. So almost like it simply ignores the max parameter.

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

Alright, sorry this has taken so long. I had all but given up hope for this extension, but here it is again. Another release that should fix the max problem. Download it again from the first post in this thread.

       
Jamie Pittock's avatar
Jamie Pittock
108 posts
18 years ago
Jamie Pittock's avatar Jamie Pittock

Mark, something not quite right going on 😊

There are 10 entries, 3 are set to Yes on ‘casestudy-featured’. (I’m not sure if those numbers actually relate to the problem or not).

I just want to display one entry that has been set to yes.

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

That displays nothing. Change the max value to anything up to 4 and still nothing displays.

Change it to 5 and 1 entry displays. Change it to 6 and 2 display, 7 and 3 display. Anything above 7 and 3 display (the maximum number of entries set to Yes).

Hope that helps.

       
1 2 3 4 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.