I’m trying to write a conditional statement depending on whether a tag returns anything. The catch is that the tag includes a parameter based on a variable. This is what I’m trying:
{if exp:seo:title entry_id="{entry_id}"}{exp:seo:title entry_id="{entry_id}"}{if:elseif title}{title}{if:else}{site_name}{/if}
Which results in an error:
You have an invalid conditional in your template. Please review your conditionals for an unclosed string, invalid operators, a missing }, or a missing {/if}.
Parser State: Unexpected ‘entry_id’ (VARIABLE); expected RD in Template “main/interior-primary-left” on line 8.
I feel like I’m probably doing something dumb. Help is appreciated!
Is the exp:seo:title
tag coming from an add on? If yes I would recommend checking their documentation to see if they have a way to handle it with that add on.
I assume you are trying to set up the meta title tag for your site to be more dynamic based on the page you’re visiting. If that is the case, I would recommend using a custom field in your channel, and layouts in the template allowing you to have more control. Instead of an add on.
In example I typically create an seo_title
in my Channel. Then in the template I pass that value to a Layout Set
{exp:channel:entries channel='channel_name'}
{layout:set name='meta_title'}
{if seo_title}
{seo_title}
{if:else}
{title}
{/if}
{/layout:set}
{/exp:channel:entries}
Then in the Layout itself I do this
<!-- meta data, per page -->
<title>{if layout:meta_title}{layout:meta_title} {if segment_1}/ {/if}{/if}{site_name}</title>
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.