Custom Attribute if nothing is entered show CollectionName
Permalink
Hello,
I have set up a custom attribute to sit inside my <h1> if nothing if displayed I want to just have the default page title. I can do this with an if/else statement I expect but not too sure how to go about it.
Code for my attribute
Now I want to add if nothing entered here use
I have set up a custom attribute to sit inside my <h1> if nothing if displayed I want to just have the default page title. I can do this with an if/else statement I expect but not too sure how to go about it.
Code for my attribute
<h1><?php echo $c->getCollectionAttributeValue('heading_1') ?></h1>
Now I want to add if nothing entered here use
<?php echo $c->getCollectionName() ?>
Hi Scott,
Thanks so much for that. There was a syntax error and after fixing it I still can't get it to work.
[code]
$echod = $c->getCollectionAttributeValue('heading_1');
if(!echod || !strlen($echod)){
$echod = $c->getCollectionName();
print $echod;
}
[code]
Thanks so much for that. There was a syntax error and after fixing it I still can't get it to work.
[code]
$echod = $c->getCollectionAttributeValue('heading_1');
if(!echod || !strlen($echod)){
$echod = $c->getCollectionName();
print $echod;
}
[code]
sorry about that, yeah i left off a ")" :)
I'm glad I could help.
I'm glad I could help.
The code isn't outputting anything, sorry if i wasn't clear in my previous post that it wasn't working after the syntax fix.
That's the easiest way.