0
votes

I'm using Drupal 6.

In ./modules/node/node.module, the following outputs the submission info in the node view:

/**
 * 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),
    ));
}

Obviously I don't want to alter the code of a core module so I'm thinking what I'd like to do is create a new module that simply overrides this function by returning an empty string. How would I do that?

Or, even simpler, is there an administrative way to remove submission settings in node pages?

4

4 Answers

2
votes

If you just don't want it to be displayed in the node view, there is an administrative way to get rid of it, based on the content type. For example you can disable it for the content type "product" or "partner" but keep it for the content type "blog post". This option can be found in admin/build/themes/settings and it's called "Display post information"

1
votes

2 ways

1: in your template.php put [theme_name]_node_subbmitted()

function [your_theme_name]_node_submitted($node) {
  return t('blah blah !username on @datetime',
    array(
      '!username' => theme('username', $node),
      '@datetime' => format_date($node->created),
    ));
}

2 or in your module

function [your_module_name]_node_submitted($node) {
  return t('blah blah by !username on @datetime',
    array(
      '!username' => theme('username', $node),
      '@datetime' => format_date($node->created),
    ));
}

in template is easier way of course

here is exacly how can you do it http://drupal.org/node/11811

1
votes

As you just want to remove that text, then you can say to Drupal not to show that information: Go to admin/build/themes/settings, and de-select the content types for which you don't want to show that string. In the screenshot, the "submitted by" information is not shown for the "Page" content type, but it is shown for the other content types.

screenshot

If you wanted to alter the string basing on some criteria, and use (for example) a different string basing on the content then you could alter the theme function called when Drupal (or any modules) call theme("node_submitted", $node), which means you would need to implement hook_theme_registry_alter(), using code similar to the following one:

function mymodule_theme_registry_alter(&$theme_registry) {
  if (isset($theme_registry['node_submitted'])) {
    $theme_registry['node_submitted']['function'] = 'theme_mymodule_node_submitted';
  }
}

If you only want to use a different string, that is always used instead of "Submitted by !username on @datetime," there are easier alternatives:

  • Using the String Overrides module you can replace any string a module passes to t() with another string you prefer.
  • Adding the following code in settings.php you can obtain the same result.

    $conf['locale_custom_strings_en'] = array(
      'Submitted by !username on @datetime' => 'The string you want to use',
    );
    

The pro of the second method is that you don't need to use another module, but you need to alter the settings.php, which is not as easy as the first method.

Between using a theme function in a theme, and using a module, I would rather use a module, as it doesn't require to change the used theme; in the case the users are able to set a theme for themselves, this means not altering all the selectable themes. The other pro is that, in the case you want to use the original string, you just need to disable the module.

0
votes

This probably should be on drupal.*?

http://drupal.org/project/submitted_by is an alternative solution give that not all themes will honour the override above, at least not in D6.