Let me preface this by saying that I am new to Drupal, I am not a developer but I can hack around a code and get things done. I have downloaded the Header Image module in order to match a header image with a particular node(s). I included the snippet in my template.php file:

/**
 * PPP
 */
function PPP_regions() {
  return array(
      'content' => t('content'),
      'top_menu' => t('top menu'),
      'sidebar_left' => t('sidebar left (for admin)'),
      'footer_message' => t('footer message')
  );
}

/**
* Return a themed breadcrumb trail.
*
* @param $breadcrumb
*   An array containing the breadcrumb links.
* @return a string containing the breadcrumb output.
*/
function phptemplate_breadcrumb($breadcrumb) {
unset($breadcrumb[0]);
array_unshift($breadcrumb, array_shift($breadcrumb) );

return '<div class="breadcrumb">'. implode(' &raquo; ', $breadcrumb) .'</div>';
}

/**
 * Custom implementation of theme_headerimage_block()
 *
 * To show the full node with title, taxonomy, etc. 
 */
function PPP_headerimage_block($node) {
  if (!$node->status) {
    $output  = '<div class="node-unpublished">';
  }

  if (module_exists('taxonomy')) {
    $terms = taxonomy_link('taxonomy terms', $node);
  }

  $output .= t('!title by !name', array('!title' => '<h2 class="title">'. check_plain($node->title) .'</h2>', '!name' => theme('username', $node)));

  if (count($terms)) {
    $output .= ' <small>('. theme('links', $terms) .')</small><br />';
  }

  $output .= $node->teaser;

  if ($node->links) {
    $output .= '<div class="links">'. theme('links', $node->links) .'</div>';
  }

  if (!$node->status) {
    $output .= '</div>';
  }

  return $output;
}
?>

My CSS code has the background image as follow (I imagine that I don't need this?):

#headwrapper {
	margin: 0 auto;
  	height:265px;
  	background:url(images/bg-header.jpg) no-repeat top center;
  	z-index: 1;

And my page.tpl.php has this code for the headwrapper (which I also think it's not needed?):

<body>

<div id="headwrapper">
       <div id="header">
	<?php if ($site_name) { ?><h1 class='site-name'><a href="<?php print $base_path ?>" title="<?php print t('Home') ?>"><?php print $site_name ?></a></h1><?php } ?>
	<?php if ($site_slogan) { ?><div class='site-slogan'><?php print $site_slogan ?></div><?php } ?>
	<?php print $search_box ?>
		</div><!--/#header--> 
</div><!--/#headwrapper-->
	
	<div id="wrapper">

I did all of the things in the read me file, but something is still not right (I am sure that it's very simple). Is there a sample of a site using this module? Or maybe a sample template.php. Any guidance would be much appreciated.

Thanks!

Comments

sutharsan’s picture

The module is used at my own site: http://link3.nl for both the image in the header as for the image left of the content.

To display the Header image, first you need to assign the Header Image block to a region. If the default regions of your theme does not suit your needs, you need to create a region (see below). As a test put the Header Image block in a site bar region which is always displayed, for example where the navigation is.

If you want only the node content to be displayed in the block you do not need to add any custom code in the template.php. By default the content is displayed in teaser view without the node title, without links, without taxonomy. Only if you need to change this default, you add the snippet from the readme.txt to your template.php.

To add a region to your template, Do something like this in template.php:

/**
 * define regions
 **/
function mytheme_theme_regions() {
  return array(
    'headerimage' => t('My header image'),
    'sidebar' => t('Sidebar navigation'),
  );
}

Add something like this in page.tpl.php:

  <div id="branding-image">
    <?php print $headerimage ?>
  </div> <!-- /#branding-image -->

Assign the Header Image block to the My header image region and you are done.

sutharsan’s picture

Status: Active » Fixed

If the issue still exist, feel free to re-open the issue.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.