Using page attributes in a template
Permalink 5 users found helpful
I am trying to create a template in which the page title (meta_title) is automatically be displayed in an H1 tag. How can you use page attributes in a template? Or is there a better way to do this?
Here's how you get the attribute value from withing a template:
It seems like a bit too much work & there may be a simpler way to do it..
<? Loader::model('collection_attributes'); $ak = CollectionAttributeKey::getByHandle('meta-description'); $value = $c->getCollectionAttributeValue($ak); echo $value; ?>
It seems like a bit too much work & there may be a simpler way to do it..
Yeah, I forgot you can pass in the handle, that makes it much easier
<?php echo $c->getCollectionName() ?>
This will display the page name, but it call also be done with other page attributes, simply by using:
<?php echo $c->getCollectionAttributeValue('attribute_name') ?>