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

Oxygen Smith's avatar
Oxygen Smith
120 posts
17 years ago
Oxygen Smith's avatar Oxygen Smith

Thanks for this awesome extension, Mark. It eliminates the need to use the query tag in most of my uses.

However, I get an SQL error when I try the SQL insert method. Attempting this on a “survey” weblog, I’m trying this.

{exp:weblog:entries weblog="{my_weblog}" surveyverified="yes" AND sql1="(" survey_city1="Edmonton" sql2=" OR " survey_city2="Calgary" sql3=")" orderby="survey_ward" sort="asc" status="Published" category="9" disable="trackbacks|pagination|member_data"}

It works perfectly fine if I get rid of the SQL inserts and split up this into two exp:weblog:entries calls, eg. one for Edmonton and one for Calgary. But, what I would like to do is get every survey entry except the ones for Edmonton and Calgary. So ultimately I want to say survey_city=”!=Edmonton” and “!=Calgary”.

Any idea what I might be doing wrong? The parentheses seem logically placed to me. Thanks again, Mark…

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

Oxygen,

Try this:

{exp:weblog:entries weblog="{my_weblog}" surveyverified="yes" AND sql1="(" survey_city__1="Edmonton" sql2=" OR " survey_city__2="Calgary" sql3=")" orderby="survey_ward" sort="asc" status="Published" category="9" disable="trackbacks|pagination|member_data"}

I’m still trying to figure out the best way to do multiple instances of the same field, but the latest version of the extension calls for two underscores then a digit.

       
Mikee Bee's avatar
Mikee Bee
179 posts
17 years ago
Mikee Bee's avatar Mikee Bee

Hi again Mark, would you mind having a quick peak at my question on page 8 ot this thread please. I’m desperate for a solution! Many thanks

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

@Mikee Bee - It’s certainly something I’m working on, but I don’t yet have an ETA for you.

       
Mikee Bee's avatar
Mikee Bee
179 posts
17 years ago
Mikee Bee's avatar Mikee Bee

Could you suggest a work around in the meantime? This is my particular issue

Thanks Mark

       
Sam C's avatar
Sam C
16 posts
17 years ago
Sam C's avatar Sam C

Hmm, I can’t see to get this to hook in. Running EE 20070627 + v218 of the plugin, I’ve tried to enable/re-enable, and I’ve added the hooks into mod.weblog.php.

My test case is a very simple:

{exp:weblog:entries weblog="sermons" limit="5" sermon_speaker="xxx"}

But the “xxx” is ignored, all rows are returned, and the SQL trace doesn’t show it being added in as a condition.

This is probably something stupid, but are there are any other debug steps I can take?

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

@Mikee Bee - For this I usually just place a conditional within my category listing. Of course you’re still pulling in all the categories, and for large category groups this isn’t ideal, but I usually work with groups of 30 or less. Something like this:

{exp:weblog:categories…} {if custom-field=='value'}{category_name}{/if} {/exp:weblog:categories}

@Sam123 - If you’re comfortable with PHP then you could go into the extension and place a var_dump('test'); at the top of the modify_sql() method. Then if you see test you know the extension is running. A few things to check: (1) are you sure sermon_speaker is the exact name of the custom field? (2) Have you tries any other fields? (3) Can you turn on template debugging, is the correct weblog:entries tag shown within the template debugger? (4) Can you turn on SQL debugging, does INNER JOIN appear anywhere within the SQL debugging?

       
Mikee Bee's avatar
Mikee Bee
179 posts
17 years ago
Mikee Bee's avatar Mikee Bee

But the conditonal is based on the custom fields within the weblog tag isn’t it so the conditonal will always return false

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

Mikee Bee - Hum. I guess I’m not understanding your problem. Can you copy/paste me some sample code, of what you’d ideally like to do? Thanks.

       
Mikee Bee's avatar
Mikee Bee
179 posts
17 years ago
Mikee Bee's avatar Mikee Bee

Here is a full explanation of what I’m trying to do

http://ellislab.com/forums/viewthread/56558/

Does that clarify things?

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

So, if I understand correctly you’re trying to get all categories with entries that have custom-field-xx set to ‘yes’. Is that correct? If so then this is way out of the scope of this extension. I did offer a query though over here: http://expressionengine.com/…

       
Mikee Bee's avatar
Mikee Bee
179 posts
17 years ago
Mikee Bee's avatar Mikee Bee

Yes thats what I’m after. I’ll see if the query option works… Anyway I’ll pick it up with you on the other post. Thanks Mark

       
Oxygen Smith's avatar
Oxygen Smith
120 posts
17 years ago
Oxygen Smith's avatar Oxygen Smith
I’m still trying to figure out the best way to do multiple instances of the same field, but the latest version of the extension calls for two underscores then a digit.
{exp:weblog:entries weblog="{my_weblog}" surveyverified="yes" AND sql1="(" survey_city__1="Edmonton" sql2=" OR " survey_city__2="Calgary" sql3=")" orderby="survey_ward" sort="asc" status="Published" category="9" disable="trackbacks|pagination|member_data"}

The above worked and the above also worked when I used negatives (“neither Edmonton nor Calgary”). Awesome. Perfect. Thanks Mark!

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

@Oxygen Smith - Superb! Thanks for the update.

       
Sam C's avatar
Sam C
16 posts
17 years ago
Sam C's avatar Sam C

Thanks Mark, template debugging helped. I can see the modify_sql method being called.

There’s no INNER JOIN present in the SQL, and I’ve tried using a number of different custom fields.

Debugging the PHP I’ve noticed that when I check the contents of this array (lines 159-166)

$SESS->cache['mh_cfields']

It contains about 25 numbers which look like ID’s.

Therefore this test is failing:

if(isset($SESS->cache['mh_cfields'][$key]))

Because $key is the name of the tag parameter (ie. ‘sermon_speaker’). This seems to be the problem.

Any ideas?

       
First 11 12 13 14 15 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.