I added a custom field in the ‘article‘ content type.
I am using bootstrap as a theme.
I want to print that field value as a css class in the h1 element of every node of type : article
So I duplicated the page.tpl.php in my subtheme template folder and changed the h1 code from :
<h1 class="page-header"><?php print $title; ?></h1>
<h1 class="page-header <?php print $node->field_custom_field['und']['value']; ?>"><?php print $title; ?></h1>
The problem is that sometimes sometimes I get this error message
Notice: Undefined property: stdClass::$field_custom_field in include() (line 157 of /home/frost/sites/all/themes/subtheme/templates/page.tpl.php).
I have basic php knowledge, so my guess is I need to add a condition saying that the custom field is only printed if the template file is called when an article content type node is being viewed.
How can I add this condition in the template file ?