In template.php
template.php I have created the following function:.
function mytheme_preprocess_node__post_esl_material(&$variables){
$variables['linking'] = 'yes baby';
}
In node--post-esl-material.tpl.php
node--post-esl-material.tpl.php I am trying to:
print $linking;
It print $linking
, but it is not working. The reason I am trying this is because I heard from an expert in Drupal that "template files are usually used to change the CSS, you do not want to put too much PHP logic here. The PHP logic is typically included in your template.php
file.".saying:
Template files are usually used to change the CSS. You do not want to put too much PHP logic here. The PHP logic is typically included in your template.php file.
Therefore the objective, after getting the above code to work, would be to, for example:
Create a variable in
template.php$article
:$article variable in template.php.
Swap the following code from
node--post-esl-material.tpl.php
into template.php.if (empty($content['field_article'])) { echo ''; } else { echo '<div class="article">'; echo '<h4>ARTICLE</h4>'; echo '<div class="field_article">'; print render($content['field_article']); echo '</div>'; echo '</div>'; }
Print
template$article
innode--post-esl-material.tpl.php
: and hence, have the PHP logic within template.php.
if (empty($content['field_article']))
echo '';
else {
echo '<div class="article">';
echo '<h4>ARTICLE</h4>';
echo '<div class="field_article">';
print render($content['field_article']);
echo '</div>';
echo '</div>';
}
3.Print $article
in node--post-esl-material.tpl.php
and hence, haveI am using Drupal 7 with the PHP logic within template.php
Stark theme.