Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a special page called www.mydomain.com/special (whcih is a page node type). Only on that specific page, I want an extra image in the header of that page (next to the logo)

The logo and sublogo's is contained in the page.tpl.php provided by the previous themer.

What I would like to add in the page.tpl.php is somthing like:

if I am on page xyz
  <div>extra logo</div>

It this possible or am I totally wrong?

share|improve this question
yes it is possible, are you using Drupal 6 or 7 ? check the naming convention for specific page here drupal.org/node/1089656 – Bala Feb 17 '14 at 13:50
Are you adding an additional logo or swapping out the logo for one page? – MPD Feb 17 '14 at 15:08

If you know the node NID of this special page, it would be a quick...

<?php if ($_GET['q']=='node/NID'): ?>
  <div>extra logo</div>
<?php endif; ?>

...in your page.tpl.php file. You could also create a special template for this node:

page--NID.tpl.php // for Drupal 7
page-NID.tpl.php  // for Drupal 6

...and have it in there all the time.

If you want to make sure that www.example.com/special uses a special template regardless of what node/NID it is really, eg, special is really an alias for node/6 or something, then you will need to get a bit more "special" with some preprocessing to look at the path alias and check if it is special and then do things different. And I say preprocessing because there should be as little logic in the templates as possible.

share|improve this answer

current_path() function should be available in page.tpl.php. Just check the result and add what you need.

Or, like pointed out in the comment, duplicate page.tpl.php and name it page--special.tpl.php, clear your cache, and add what you need. Keep in mind that this new .tpl will apply only to your /special page, so you wont need to check the url.

share|improve this answer

If could, in template.php of your theme, declare preprocess_page hook and add a variable:


function yourtheme_preprocess_page(&$vars) {      
  // Change this "if" with your logic
  if (current_path() == 'mypage') {
    $vars['custom_text'] = 'custom text';


Next, in your page.tpl.php, add the variable near the title, like this:

<h2><?php print $title ?>
  <?php if ($custom_text) { print $custom_text; } ?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.