I'm in the process of developing a news-style site and so I wanted the "submitted by" to have a custom look based on the node type. In other words, I wanted blog posts to have a custom "submitted by" that was different from the custom "submmitted by" for news articles.

Here is what I came up with:

<?php if ($submitted) { ?>
    <span class="submitted">
<?php  if ($node->type == 'blog') {
       print
'Posted ' . format_date($node->created, 'custom', "F jS, Y") . ' by ' . theme('username', $node);
       }
       else {
       print
'By ' . theme('username', $node) . ' <br /> ' . format_date($node->created, 'custom', "F jS, Y") ;
       }
?>

    </span>
<?php } ?>

(Note: I disabled "submitted by" for 'page' in themes > configure > global settings.)

Hope this is useful to someone.

Cheers,
Carey

Comments

thanks for the tip! : )

may want to refer to the 'page' in your note as 'content type'
My first reaction was to shut that off on "page" until i went back and reread the snippet that stated blog.

Thus, this method can be used on any type of content type.

I did mean that I shut off the "submitted by" for 'page' - that is, all pages.

On my site I use 'page' for what would normally be static html pages (I don't want a "submitted by" on them), 'story' for articles, and 'blog' for all blog posts. Articles are more formal newsy writings and blog posts are more informal opinion writings. That's how I've distinquished them, anyways.

Yes, you are right, though. This can be used for any content type. I just chose to use it this way....And with an 'elseif' statement in between, another content type can have its own custom "submitted by" too - like 'page' just displaying date.

Perhaps it should have been clarified that this code goes in your theme's comments.tpl.php.

---
Like what you see? Leave a tip!
spiffy[d] | simplicity is bliss

This works great! Instead of adding conditionals I used it inside node-blog.tpl.php in order to customize the message for blog posts.

Thanks for the tip! This is awesome.