is it possible to customize the "Submitted by" line for different types of nodes?

for instance, I would like forum topics to say "Posted by..." since users can post them without approval; and book pages to say "Submitted by..." since they go into the queue.

I've been hacking my way through the Xtemplate theme, so far to no avail.

Comments

ti’s picture

You might find this thread helpful.

pruner’s picture

that thread only deals with hiding the "Submitted by" line for a particular node type... not customizing it for different types.

Stefan Nagtegaal’s picture

Change the following lines inside xtemplate.theme under function xtemplate_node():
$xtemplate->template->assign(array(
"submitted" => t("Submitted by %a on %b.",
array("%a" => format_name($node),
"%b" => format_date($node->created))),

switch ($node->type) {
case 'page':
$xtemplate->template->assign(array(
"submitted" => t("Submitted by %a on %b.",
array("%a" => format_name($node),
"%b" => format_date($node->created)))));
break;
case 'story':
case 'blog':
case 'forum':
$xtemplate->template->assign(array(
"submitted" => t("Posted by %a on %b.",
array("%a" => format_name($node),
"%b" => format_date($node->created)))));
break;
}

This is untested, but i'm pretty sure this should work...

pruner’s picture

it caused a parse error.

what did work is adding the lines you suggested:

switch ($node->type) {
   case 'page':
    $xtemplate->template->assign(array(
        "submitted" => t("Submitted by %a on %b.",
        array("%a" => format_name($node),
        "%b" => format_date($node->created)))));
   break;
   case 'story':
   case 'blog':
   case 'forum':
     $xtemplate->template->assign(array(
        "submitted" => t("Posted by %a on %b.",
        array("%a" => format_name($node),
        "%b" => format_date($node->created)))));
     break;
 }

just below this:

$xtemplate->template->assign(array(
         "submitted" => t("Submitted by %a on %b.",
                       array("%a" => format_name($node),
                             "%b" => format_date($node->created))),
       "link"      => url("node/view/$node->nid"),
        "title"     => $node->title,
        "author"    => format_name($node),
        "date"      => format_date($node->created),
        "static"    => ($main && $node->static) ? 'static' : '',
        "content"   => ($main && $node->teaser) ? $node->teaser : $node->body));

above this:

if ($page == 0) {
    $xtemplate->template->parse("node.title");
  }

thanks for your help. :-)