I would like to be able to customise the way a node is displayed, if that node is the front page. i.e. if Administer->Settings->Default Front Page is set to some node, I want to render that node without the submitted by etc links as it's my "front page" current CVS PHPTemplate can not do this.

I have modified my copy to work, I am unable to supply a regular patch file at this time (no access to diff and cvs from here), however, this is the new version of the function:

/**
 * Prepare the values passed to the theme_node function to be passed
 * into a pluggable template engine. 
 */
function phptemplate_node($node, $main = 0, $page = 0) {
  global $node_cache;
  $node_cache[] = $node;

  if (module_exist('taxonomy')) {
    $taxonomy = taxonomy_link('taxonomy terms', $node);
  }
  else {
    $taxonomy = array();
  }

   if ($_GET['q'] == variable_get('site_frontpage', 'node')) {
    $frontpage = true;
  }
  
  $vars = array(
      'title'          => $node->title,
      'node_url'       => url('node/' . $node->nid),
      'terms'          => theme('links',$taxonomy),
      'name'           => format_name($node),
      'date'           => format_date($node->created),
      'sticky'         => $node->sticky,
      'picture'        => theme_get_setting('toggle_node_user_picture') ? theme('user_picture', $node) : '',
      'content'        => ($main && $node->teaser) ? $node->teaser : $node->body,
      'links'          => theme('links', $node->links),
      'mission'        => $mission,
      'page'           => $page,
      'taxonomy'       => $taxonomy,

    /* Lastly , pass the actual node to allow more customization */
      'node'           => $node,
      'main'           => $main,
      'page'           => $page
      'is_front'       => $frontpage,
    );

  // Display info only on certain node types. 
  if (theme_get_setting('toggle_node_info_' . $node->type)) {
    $vars['submitted'] =  t('Submitted by %a on %b.', array('%a' => format_name($node), '%b' => format_date($node->created)));
  }

  return _phptemplate_callback('node', $vars, 'node-' . $node->type);
}

The changes are to add:

  if ($_GET['q'] == variable_get('site_frontpage', 'node')) {
    $frontpage = true;
  }

(lifted from phptemplate_page)

and to pass that into the array:

'is_front'            => $frontpage,

Sorry I can't provide a patch from this system :(

This allowed me to do:

<div class="node<?php print ($sticky) ? " sticky" : ""; ?>">
  <?php print $picture ?>
  <?php if ($page == 0): ?>
    <h1 class="title"><a href="/<?php print $node_url ?>"><?php print $title ?></a></h1>
  <?php endif; ?>
    <?php if (!$is_front): ?>
      <span class="submitted"><?php print $submitted ?></span>
      <span class="taxonomy"><?php print $terms ?></span>
    <?php endif; ?>
    <div class="content"><?php print $content ?></div>
    <?php if (!$is_front): ?>
      <?php if ($links): ?>
      <div class="links">&raquo; <?php print $links ?></div>
      <?php endif; ?>
    <?php endif; ?>
</div>

To hide some items I don't want on the front page of the site.

Mike

Comments

audioel’s picture

Hi,

I had to make some minor changes with $links in the above code for it to work on my 4.5.2 install. Once that was done, it worked great!

Thanks,

Gustavo

// modified code starts below to add "is_front" variable

function phptemplate_node($node, $main = 0, $page = 0) {
  global $node_cache;
  $node_cache[] = $node;
  if (module_exist('taxonomy')) {
    $taxonomy = taxonomy_link('taxonomy terms', $node);
  }
  else {
    $taxonomy = array();
  }
   if ($_GET['q'] == variable_get('site_frontpage', 'node')) {
    $frontpage = true;
  }
  $links = link_node($node, $main);
  $vars = array(
      'title'          => $node->title,
      'node_url'       => url('node/' . $node->nid),
      'terms'          => theme('links',$taxonomy),
      'name'           => format_name($node),
      'date'           => format_date($node->created),
      'sticky'         => $node->sticky,
      'picture'        => theme_get_setting('toggle_node_user_picture') ? theme('user_picture', $node) : '',
      'content'        => ($main && $node->teaser) ? $node->teaser : $node->body,
      'links'          => ($links != '') ? theme('links', $links) : '',
      'mission'        => $mission,
      'page'           => $page,
      'taxonomy'       => $taxonomy,
    /* Lastly , pass the actual node to allow more customization */
      'node'           => $node,
      'main'           => $main,
      'page'           => $page,
      'is_front'       => $frontpage,
    );
  // Display info only on certain node types.
  if (theme_get_setting('toggle_node_info_' . $node->type)) {
    $vars['submitted'] =  t('Submitted by %a on %b.', array('%a' => format_name($node), '%b' => format_date($node->created)));
  }
  return _phptemplate_callback('node', $vars, 'node-' . $node->type);
}

// end changed code
urbanlegend’s picture

Version: » 4.6.x-1.x-dev
Status: Needs review » Closed (outdated)

Given that this issue has not been updated in 11 years or more, I am closing this ticket as outdated (no longer needed and/or relevant). However, if anyone feels this represents an issue that is still being encountered in the current version of Drupal, please reopen and/or provide additional comments.