Using Drupal 7.10 with a Zen sub-theme. I have a custom content type, say Product. The products have titles such as "Wrench", "Hammer", "TV". I want to designate certain products as being a recommended product by having a little star icon appear inline after the title.
So for example:
Wrench
Hammer *
TV
Scooter
Piano *
Whether the star appears or not should be based on a boolean field I added to the product content type. I want the star to appear when viewing the node directly or when the node appears as part of a list in a view.
My thought was to put an if statement in the node template for my content type, e.g. node--product.tpl.php. However, what has me stuck is that in Zen it appears, if you are viewing a node as a page then the title is rendered in the page template, and if you're not viewing the node as a page then the title is rendered in the node template. I'm not sure how to reconcile this. Furthermore, I'm not sure if my field variable would even be available directly from the page template.
UPDATE
It appears I can successfully create a boolean preprocess variable in the function mytheme_preprocess_page
whose value is based on field from the node:
function mytheme_preprocess_page(&$variables, $hook) {
//$variables['sample_variable'] = t('Lorem ipsum.');
if (isset($variables['node'])
&& $variables['node']->type == 'mycontent_type') {
if($variables['node']->field_is_recommended
&& $variables['node']->field_is_recommended[LANGUAGE_NONE][0]['value'] == 1) {
$variables['is_recommended'] = TRUE;
}
else {
$variables['is_recommended'] = FALSE;
}
}
}
So now that I know this is possible, what's the best way for me to do this?