Is it it possible to apply a conditional to a custom category field?
Example:
On a single entry page
entry is in category A
custom field for category A is cat_color
Can I say:
{if cat_color}
Do this….
{/if}This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
September 13, 2008 12:29pm
Subscribe [2]#1 / Sep 13, 2008 12:29pm
Is it it possible to apply a conditional to a custom category field?
Example:
On a single entry page
entry is in category A
custom field for category A is cat_color
Can I say:
{if cat_color}
Do this….
{/if}#2 / Sep 13, 2008 3:56pm
Yep, sure can! Give it a shot. =) Just make sure any category variables are inside the {categories} variable pair.
#3 / Sep 13, 2008 5:43pm
Lisa, I’m actually trying to do the exact same thing as NetBuilder and it’s not working in EE v1.6.4. Here is my code:
{categories show_group="15"}{if brand-url}website{/if}]{/categories}
Are you sure conditionals can be used on custom category fields?
Anna
#4 / Sep 13, 2008 6:20pm
I used them when initially testing this functionality, so should be able to. What is the rest of your code?
#5 / Sep 13, 2008 6:29pm
Here is what my complete template looks like:
{embed=zrecs-guide/_header}
{exp:weblog:category_heading weblog="zrecs-guide"}
<h1>{category_name}</h1>
{/exp:weblog:category_heading}
{exp:weblog:entries weblog="zrecs-guide" limit="6" disable="member_data|trackbacks|category_fields" paginate="bottom" orderby="title" sort="asc"}
<div class="black-line"></div>
<div class="article-copy">
{exp:imgsizer:size src="{quide-image}" width="200" alt="{title}" class="grid-image"}
<h2>{title}</h2>
<p> {embed="global/edit-link" w="{weblog_id}" e="{entry_id}"}<br />
<br />
<b>Ingredients of concern:</b> <br />
{embed="zrecs-guide/embed-ingredients" e="{entry_id}"}<br />
<br />
<b>Confidence:</b> {categories show_group="18"}/images/site/{category_name}.jpg {category_name}{/categories} <br />
<b>Rating:</b> {categories show_group="14"}/images/site/{category_name}.jpg{/categories} <br />
<b>Price:</b> {categories show_group="17"}/images/site/{category_name}.gif{/categories} <br />
<b>Sizes:</b> {quide-sizes}<br />
<b>Manufacturer:</b> {categories show_group="15"}{category_name} [<a href="http://{path=zrecs-guide/category-detail}">listings</a>{if brand-url} |<a href="http://{brand-url}" target="_blank" rel="noopener">website</a>{/if}]{/categories}<br />
{guide-copy}<br />
<b>Purchase:</b> {guide-purchase}<a href="http://{col_2}" target="_blank" rel="noopener">{col_1}</a> | {/guide-purchase}<br />
</div></p>
<p> {paginate}<br />
<div class="colorbar">{pagination_links}</div><br />
{/paginate}</p>
<p> {/exp:weblog:entries}</p>
<p>{embed=zrecs-guide/_footer}#6 / Sep 15, 2008 8:58pm
Bump…
#7 / Sep 15, 2008 9:00pm
What version and build are you on again? Also, can you try greatly reducing that? Something like:
{exp:weblog:entries limit=5"}
{categories}
{custom_field}
conditional testing custom field
{/categories}
{/exp:weblog:entries}and give us a link to the test?
#8 / Sep 15, 2008 9:33pm
ExpressionEngine 1.6.4
Build: 20080710
Test page is here:
REMOVED BY MEDIAGIRL
In the template is:
{exp:weblog:entries weblog="zrecs-guide" limit="25"}
{categories show_group="15"}{category_name} [{if brand-url} <a href="http://{brand-url}" target="_blank" rel="noopener">website</a>{/if}]{/categories}
{/exp:weblog:entries}#9 / Sep 15, 2008 9:39pm
Just spotted the problem:
disable=“member_data|trackbacks|category_fields”
I had category_fields in my disable parameter. Works great the second I remove it!
Thank you, thank you. Anna
#10 / Sep 15, 2008 9:41pm
Ah, I can’t believe I didn’t spot that. Glad you found it!
#11 / Sep 15, 2008 9:44pm
Your suggestion to strip down the template led me right to it.
A big thank you as always.
Anna
#12 / Sep 15, 2008 9:55pm
My pleasure, Anna. Reduction testing has saved me hundreds of hours squinting at the screen, trying to find that elusive…. thing. Usually a semi-colon. =)