Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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>
endif

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 at 13:50
    
Are you adding an additional logo or swapping out the logo for one page? –  MPD Feb 17 at 15:08

3 Answers 3

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:

<?php

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; } ?>
</h2>
share|improve this answer

Your Answer

 
discard

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.