How to remove only "Submitted by " in this text: "Submitted by [username] on Mon, 11/24/2008 - 13:51."

Comments

in the admin page ?q=admin/build/themes/settings you can disable these per content type


Alan Davison
www.caignwebs.com.au

Alan Davison
Back roads somewhere in South America

It will remove entire "Submitted by [username] on Mon, 11/24/2008 - 13:51."

I have to remove only "Submitted by "

In your theme, override the standard function using (Drupal 6)

<?php
/**
* Format the "Submitted by username on date/time" for each node
*
* @ingroup themeable
*/
function THEME_NAME_node_submitted($node) {
  return
t('!username on @datetime',
    array(
     
'!username' => theme('username', $node),
     
'@datetime' => format_date($node->created),
    ));
}
?>

Just remember to flush the cache after creating the function. Under admin > settings > site performance


Alan Davison
www.caignwebs.com.au

Alan Davison
Back roads somewhere in South America

I need it for Drupal 5 :-)

it worked splendidly.

Also checked out your site, really nice and clean design. And the about us picture of your managing director with different photos of him is quite clever and simple.

Very similar:

Just cut 'n' pasted from Drupal 5 node.module. Change theme to your theme name as per above, and change the text.

<?php
/**
* Format the "Submitted by username on date/time" for each node
*
* @ingroup themeable
*/
function theme_node_submitted($node) {
  return
t('Submitted by !username on @datetime',
    array(
     
'!username' => theme('username', $node),
     
'@datetime' => format_date($node->created),
    ));
}
?>

Alan Davison
www.caignwebs.com.au

Alan Davison
Back roads somewhere in South America

> Just cut 'n' pasted from Drupal 5 node.module

Sorry, I was looking for "Submitted by " in Drupal 5 node.module, but didn't find it.

Are you running phptemplate based engine?

If so, modify the standard garland function in your theme:

<?php
/**
* Override or insert PHPTemplate variables into the templates.
*/
function _phptemplate_variables($hook, $vars) {
  if (
$hook == 'page') {
    if (
$secondary = menu_secondary_local_tasks()) {
     
$output = '<span class="clear"></span>';
     
$output .= "<ul class="tabs secondary">\n". $secondary ."</ul>\n";
     
$vars['tabs2'] = $output;
    }
   
// Hook into color.module
   
if (module_exists('color')) {
     
_color_page_alter($vars);
    }
    return
$vars;
  }
 
// NEW CODE
 
if ($hook == 'node') {
    if (
theme_get_setting('toggle_node_info_' . $vars['node']->type)) {
     
$vars['submitted'] = t('!a on @b.', array('!a' => theme('username', $vars['node']), '@b' => format_date($vars['node']->created)));
      return
$vars;
    }
  }
  return array();
}
?>

I haven't run it but it should be fairly painless...


Alan Davison
www.caignwebs.com.au

Alan Davison
Back roads somewhere in South America

I am using "Zen" theme. So, where should this code go?

Maybe it's easier just to find a phrase "Submitted by" and change it? Can you tell where it is?

Similar code, just modify zen's version of the same file.

The base variable is defined in phptemplate.engine in themes/phptemplate


Alan Davison
www.caignwebs.com.au

Alan Davison
Back roads somewhere in South America

Thank you. Problem solved.

I'm using Drupal 6 and need to implement this code. Which file do I paste the code into?

It is theme dependent, but paste the fragment from http://drupal.org/node/338814#comment-1124940 in to your themes template.php file


Alan Davison
www.caignwebs.com.au

Alan Davison
Back roads somewhere in South America

I actually need to remove "Submitted by user on ".

Thanks!

Just modify the code to:

<?php
function THEME_NAME_node_submitted($node) {
  return
format_date($node->created);
}
?>

:)


Alan Davison
www.caignwebs.com.au

Alan Davison
Back roads somewhere in South America

I appreciate the help. I've ONE more question (I promise!)

How do I remove the "USER's blog" link?

-Carl.

This one requires a hook_link_alter, or a custom module. (Untested code)

Eg:

<?php
function MYMODULE_link_alter(&$links, $node) {
  foreach (
$links as $key => $link) {
    if (
$key == 'blog_usernames_blog') {
      unset(
$links['blog_usernames_blog']);
    }
  }
}
?>

As such, do a search of the forums to see if there is an easier solution, and if not, it may be time to learn some PHP and get into the core of Drupal and create your own module. The site api.drupal.org has some great example modules, just do a function search on 'example'.

PS: If there is a class or id on the link, you may be able to simply hide it. eg: #user-blog-link { display: none; }


Alan Davison
www.caignwebs.com.au

Alan Davison
Back roads somewhere in South America

If that link is in a menu, top/sidebar/etc, then all you may need to do is to look through all of your menus and find the link. Then disable it. Easy.

Eg:

List all menus
index.php?q=admin/build/menu

Configure the Nav menu (likely first place to start)
index.php?q=admin/build/menu-customize/navigation


Alan Davison
www.caignwebs.com.au

Alan Davison
Back roads somewhere in South America

The "display:none;" thing worked - I don't know why I didn't think of that myself!

However, for some reason on IE6 "Submitted by USER on " is still displaying. Any idea why this would be? It's not really hugely important but I like to be consistent.

Here's an example: http://catalysto.com/imsta/taxonomy/term/6

Thanks again!

Have you emptied the cache? On each page I see the old "Submitted by USER on ". If your not seeing this, then it is because you have either a) a different theme or b) seeing non-cached pages as you are logged in (except of the term listing page)

Try flushing this at sites > settings > performance

Cheers


Alan Davison
www.caignwebs.com.au

Alan Davison
Back roads somewhere in South America

If you're still using Drupal 5 and have a Zen subtheme, just edit the subthemename_preprocess_node() function so it looks something like this:

function firstword_preprocess_node(&$vars) {
$vars['submitted'] = t('By !a on @b.', array('!a' => theme('username', $node), '@b' => format_date($node->created)));
}

what about in your node.tpl.php change from something like this:

<?php if ($submitted): ?>
        <div class="submitted">
          <?php print $submitted; ?>
        </div>
        </div>
      <?php endif; ?>

to something like this:

<?php if ($submitted): ?>
        <div class="submitted">
          <?php print $date; ?>
        </div>
        </div>
      <?php endif; ?>

... and it's bad practice to mess with core files. You should use overrides instead as explained earlier in this thread ...

EDIT

Sorry - I posted this in the wrong thread! Please ignore this comment ...