link2this
::demo
::download
::documentation
On the Drupal forums, there have been several requests for a way to control the "posted by" and "date" information that by default is printed at the top of every page. Here is a short sketch of a method that enables the conditional display of this information based on the node type.
based on experience with Drupal 4.4.1 and the Marvin_2K Version 1.5 theme.
not tested with 4.4.2
Step 1: Modify marvin_2k.theme - add node type
By default, the Marvin2K theme does not include the node type. You must first add this to the variable array. Open marvin_2k.theme, starting around line 144 you should see the following code:
$template->set_vars( array(
"title" => $node->title,
"node_url" => url("node/view/$node->nid"),
"terms" => $terms,
"name" => format_name($node),
"date" => format_date($node->created),
"static" => $node->static,
"content" => ($main && $node->teaser) ? $node->teaser : $node->body,
"links" => ($links != "") ? theme("links", $links) : "",
"layout" => $layout,
"mission" => $mission,
"display_search" => ((variable_get("marvin_2k_search_box", 1) == 1) && (user_access("search content") == 1)),
"page" => $page, "type" => $node->type,
));Add the highlighted line - this will give you access to the node type from the template include.
Step 2: Modify node.tpl.php - add conditional display
open the templates/node.tpl.php file. Around line 6 you should see the following line, which displays the "date" and "posted by" information:
<div class="info"><?php print t("Posted by") ." ". $name ." on ". $date . $terms ?></div>Wrap a conditional statement around that line. For this example, we will hide the data for "page" nodes, and show for "story" nodes. Add the highlighted lines:
<?php
if ($type=='story') {
?> <div class="info"><?php print t("Posted by") ." ". $name ." on ". $date . $terms ?></div> <?php } ?>
Conclusion:
Using this method you can trap custom node types, or alter the logic to look for other template variables such as a specific node. Since both Drupal and the Marvin theme are evolving, this information may already be out of date. But since I spent the time figuring it out, I thought I would post a quick write up. Hope it helps!.