I just created a template page--article.tpl.php
to apply ton nodes of the [article] type
. It works when declared in the template.php
file.
My problem is that there is a very slight change compared to the generic page.tpl.php
, nothing worth having another file.
I was wondering if I could place the adde part between a condition, just as I could do with if $is_front
Something like:
<?php if ($node->type == 'article')
// render my thingees
?>
I would be glad if someone could tell me.
--- Edit, to answer Kiwimind ---
I did the test with the 'page' content type, so I didn't have to skip my page--article.tpl.php
file. I checked that 'page' was the actual machine name and 'nature' is my theme's actual name, it works on other functions.
I wrote in template.php
/**
* Détection du type de contenu pour affecter le template page
* https://drupal.stackexchange.com/questions/264550/can-i-target-a-specific-node-type-in-page-tpl-php
*/
function nature_preprocess_page(&$variables, $hook) {
$variables['is_page'] = false;
if (isset($variables['node']) && $variables['node']->type == 'page') {
$variables['is_page'] = true;
}
}
Then in page.tpl.php
<?php if ($is_page) : ?>
<h1>This is a “page” content</h1>
<?php endif; ?>
Nothing more, nothing less. Do you see any missing (or unnecessary) character, that could trigger a parse error? For I still get a whole blank page when clearing the cache.