Add custom attribute block to a template

Permalink
Does anyone know how to hard code a custom attribute block into a template?

 
wildapple replied on at Permalink Reply
wildapple
Pretty much anything you can call on with the attribute block you can get with regular old methods like page title or description or whatever. Which attributes are you trying to display?

For the sake of the question I suppose you could do something like this which would display the page title...

<?php            
$attr = BlockType::getByHandle('page_attribute_display');
$attr->controller->attributeHandle = 'rpv_pageName';
$attr->render();
?>


But it's a hell of a lot easier to just do
<?php
echo $c->getCollectionName();
?>


I'm guessing you've got a custom attribute or something going on? Can you not just grab it with the handle like so?
$myThing = $c->getAttribute('my_thing');
andrewjaff replied on at Permalink Reply
andrewjaff
Hi ,

You can use this to display text attribute of page in template

global $c;
$attr = $c->getAttribute('attribute_name');
echo $attr;
WebcentricLtd replied on at Permalink Reply
hi,
just thought I'd chime in here. This isn't really what you asked but might achieve a similar result without resorting to hardcoding and losing some flexibility In your page templates.

With page types and page templates now being decoupled you can create page types and add default blocks / attributes etc into them directly via the GUI without having to hardcode values and possibly limit the utility/flexibility of your page templates.

Just a thought. Please ignore as appropriate...
WillemAnchor replied on at Permalink Reply
WillemAnchor
to display user attributes, you could use my add-on:

http://www.concrete5.org/marketplace/addons/user-info1...