Display a simple text attribute in a page.
Permalink 1 user found helpful
I have created a new attribute called 'timings' so the editor can add some custom text into the page - but I can't seem to find out how to add this to the theme.
Hope someone can help :)
Ryan
Hope someone can help :)
Ryan
nope - doesn't work.
I have an image that is pulling in with this:
<?php
$pt = $cobj->getCollectionAttributeValue('icon');
if($pt){
$imgHelper->outputThumbnail($pt, 20,20, $title);
}
?>
I have an image that is pulling in with this:
<?php
$pt = $cobj->getCollectionAttributeValue('icon');
if($pt){
$imgHelper->outputThumbnail($pt, 20,20, $title);
}
?>
Have you checked out what is returned here:
E.g. by dumping it:
If there is null returned, then that page does not have an attribute called 'icon' defined.
I think it should work as you described for image attributes. Also, obvious question, have you correct helper in the $imgHelper variable?
$pt = $cobj->getCollectionAttributeValue('icon');
E.g. by dumping it:
var_dump($pt);
If there is null returned, then that page does not have an attribute called 'icon' defined.
I think it should work as you described for image attributes. Also, obvious question, have you correct helper in the $imgHelper variable?
Here his what you need:
http://www.concrete5.org/community/forums/customizing_c5/custom-att...
and this:
http://www.concrete5.org/documentation/introduction/cheat-sheet/...
http://www.concrete5.org/community/forums/customizing_c5/custom-att...
and this:
http://www.concrete5.org/documentation/introduction/cheat-sheet/...
Thanks for all the posts, the images are working fine but I can't pull in the a text attribute.
Just follow the cheat sheet you have all the code you need there.
$page = Page::getCurrentPage(); $your_at = $page->getCollectionAttributeValue('your_attribute'); echo $your_at;
Ok, not sure what you mean, you basically have all the answers already there.
Pulling out the image (as you described yourself):
Pulling out the TEXT attribute:
Pulling out the image (as you described yourself):
$pt = $cobj->getCollectionAttributeValue('icon'); if($pt){ $imgHelper->outputThumbnail($pt, 20,20, $title); }
Pulling out the TEXT attribute:
echo $cobj->getAttribute('your_text_attribute_name');
Thank you everyone - all fixed with:
<?php
echo $cobj->getAttribute('timings');
?>
<?php
echo $cobj->getAttribute('timings');
?>
http://c5mix.com/blog/tips/using-page-attributes-in-concrete5-theme...
Basically (if I got you correctly) the answer is:
Br,
Antti / Mainio