Hi,
I have such a record: {embed="core/template" meta_title="Lorem ipsum is dumny text"}
In the template file: <title>{if embed:meta_title == ''}Defualt text{if:else}{embed:meta_title}{/if}</title>
The code does not work. On another server, the same code works fine. The problem appeared suddenly. Did anyone meet something like that?
Everything looks good in your code. So- it was working, and suddenly broke? Is that the only thing that broke? If you have the ‘title’ bit with the embed variables on a template all by itself with nothing else, what’s it showing?
And double check PHP error logs. Let’s see if anything is weird there.
Oh- and it’s always worth very briefly disabling all extensions to make sure nothing is going weird there. But only briefly- it may break things.
If the meta_title = “” field passes empty then the default text is not displayed. It suddenly stopped working. Plugins turned off for a while but did not help.
Oddly enough, on another server I have the same code in another cms and it works fine there.
<?php $title = “{embed:meta_title}”; echo $title;?> <?php if($title == “”):?> <title>Default text</title> <?php else:?> <title>{embed:meta_title}</title> <?php endif;?>
The condition in php also doesn’t work. If the meta_title field is empty, it does not go further.
Additionally: <? php $ title = “{embed: meta_title}”; echo strlen ($ title);?> It returns 26 despite the empty string.
It’s not making much sense to me, but I may not be fully understanding everything that was happening. The weirdest bit to me would be if it was working and suddenly broke. Something definitely had to have changed for that to happen, but there’s nothing I know of that would have jammed those embed variables.
Very odd!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.