Displaying Attributes on a Page

Permalink
So here's my issue:

I've created a Page Type called "Student".

I've given "Student" a Custom Attribute called "Student Name".

I create a new page based on the "Student" Page Type, and give it "Joe P" as the value for the "Student Name" Custom Attribute.

The crucial step that I'm missing:

How do I make all instances of "Student" pages display their value of "Student Name" on the page without having to add a content block myself. IE - if I were to edit the "Student Name" Custom Attribute, it would update the page to match the new value, again without having to In-Context-Edit the page.

In other words, I want all instances the "Student" Page Type to have a Block that will display its "Student Name" Custom Attribute just by virtue of adding the page to the Sitemap.

This seems like a very basic and common thing to do, I'm just missing the tutorial / documentation page that tells me how to do it! :-) Thanks for your help!

 
beebs93 replied on at Permalink Reply
beebs93
In your "Student" page template (I assume student.php) you would put the following where you want the attribute value to be displayed:

$strStudentName = $c->getAttribute('student_name_attribute_handle_here');
if(is_string($strStudentName) && strlen($strStudentName) > 0){
   echo '<p>Student Name: ' . $strStudentName . '</p>';
}


This is just a simple example of outputting custom attribute values for a particular page. It will NOT output it to a particular block, rather, it will be hardcoded into the template. Each page you make with the "Student" page type will output the value of its "Student Name" attribute.