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

 
Mainio replied on at Permalink Reply
Mainio
With a little googling around, I found this:
http://c5mix.com/blog/tips/using-page-attributes-in-concrete5-theme...

Basically (if I got you correctly) the answer is:
$yourValue = $c->getAttribute('your_attribute_handle');


Br,
Antti / Mainio
liminal replied on at Permalink Reply
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);
}
?>
Mainio replied on at Permalink Reply
Mainio
Have you checked out what is returned here:
$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?
PauloCarvalhoDesign replied on at Permalink Reply
PauloCarvalhoDesign
liminal replied on at Permalink Reply
Thanks for all the posts, the images are working fine but I can't pull in the a text attribute.
PauloCarvalhoDesign replied on at Permalink Reply
PauloCarvalhoDesign
Just follow the cheat sheet you have all the code you need there.
PauloCarvalhoDesign replied on at Permalink Reply
PauloCarvalhoDesign
$page = Page::getCurrentPage();
$your_at = $page->getCollectionAttributeValue('your_attribute');
echo $your_at;
Mainio replied on at Permalink Reply
Mainio
Ok, not sure what you mean, you basically have all the answers already there.

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');
liminal replied on at Permalink Reply
Thank you everyone - all fixed with:

<?php
echo $cobj->getAttribute('timings');
?>