on one of my content types i have the Display author and date information enabled.

the result looks like this:
Submitted by anastasia on Mon, 06/06/2011 - 11:44

what i want to achieve is: hide author information and display time information only

the result should look like this:
Submitted on Mon, 06/06/2011 - 11:44

i want to get rid of the word "by" and the author.

the information comes from the $submit variable in the node.tpl.php but i don't know where i can change/adjust this.

any suggestions would be welcome. thanks in advance.
chris

Comments

jnz31’s picture

i was actually looking for the same and found the place to look at:
best practice is (i guess!! me = complete noob) to copy the module node into your sites/all/modules/ and change the file node.module
around line #1469 (drupal 7.4) you'll find the row
$variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date']));

nevets’s picture

Modify any core file is anything but a best practice. One can implement hook_preprocess_node() and change what is shown that way.

karschsp’s picture

StatusFileSize
new49.34 KB
new44.32 KB

I ran across this tonight, I needed to display just the date information, not the author information. I know this can be done in the theme layer, but it might be nice to offer two checkboxes on this screen.

Only local images are allowed.

Only local images are allowed.

I'm working on a patch, but may need some help. I'll post what I have shortly.

karschsp’s picture

Assigned: Unassigned » karschsp
Status: Active » Needs review
StatusFileSize
new11.4 KB

Here's the patch I mentioned above.

Status: Needs review » Needs work

The last submitted patch, publishing-options-1194470-004.patch, failed testing.

karschsp’s picture

Version: 7.2 » 8.x-dev
Status: Needs work » Needs review

Not sure why this failed. Passed locally. Also, marking as 8.x-dev.

bfroehle’s picture

Category: support » feature
Status: Needs review » Needs work
+++ b/modules/node/content_types.jsundefined
@@ -23,8 +23,11 @@ Drupal.behaviors.contentTypes = {
+        vals.unshift(Drupal.t("Don't Display submitted date."));

Change Display to display.

+++ b/modules/node/content_types.jsundefined
@@ -23,8 +23,11 @@ Drupal.behaviors.contentTypes = {
+        vals.unshift(Drupal.t("Don't Display author."));

Ditto.

+++ b/modules/node/node.moduleundefined
@@ -1464,15 +1464,25 @@ function template_preprocess_node(&$variables) {
+  }
+  ¶
+  // Display author information only on certain node types.
+  if (variable_get('node_author_' . $node->type, TRUE)) {

Extra whitespace.

+++ b/modules/node/node.moduleundefined
@@ -1464,15 +1464,25 @@ function template_preprocess_node(&$variables) {
+    $variables['author'] = t('Submitted by !author', array('!author' => $variables['name']));

Perhaps this should turn into one of 4 possibilities:

Submitted by !username on !datetime.
Submitted by !username.
Submitted on !datetime.
(noting)

Having two Submitted by phrases is clumsy.

+++ b/modules/node/node.testundefined
@@ -724,10 +725,15 @@ class NodePostSettingsTestCase extends DrupalWebTestCase {
+    $this->assertEqual(count($elements), 1, t('Date information is displayed.'));
+    ¶
+    // Check that the author information is displayed.
+    $node = $this->drupalGetNodeByTitle($edit["title"]);

Whitespace. There are lots more whitespace bugs, but I'll skip the remainder.

+++ b/themes/bartik/templates/node.tpl.phpundefined
index 1b144f1..c32f322 100644
--- a/themes/garland/template.php

+++ b/themes/garland/template.phpundefined
@@ -122,7 +122,8 @@ function garland_preprocess_page(&$vars) {
-  $vars['submitted'] = $vars['date'] . ' — ' . $vars['name'];

The testbot errors all come because you'll also need to change garland/node.tpl.php.

Is there an upgrade routine?

Obviously this isn't a candidate for inclusion in D7.

karschsp’s picture

Category: feature » support
Status: Needs work » Needs review
StatusFileSize
new5.84 KB

Here's an updated patch with a bit of a difference approach.

Instead of creating new variables, I just put the info in the existing $variables['submitted'] in template_preprocess_node() depending on which boxes they have checked. Still needs tests which I hope to get to those tonight.

I also took a stab at an upgrade path...

Status: Needs review » Needs work

The last submitted patch, display-settings-1194470-008.patch, failed testing.

karschsp’s picture

Can anyone help on tests on this? I'm not quite sure how to test the various combinations...since everything's essentially wrapped in

$submitted

naught101’s picture

Title: Display settings in a content type: Display date information but hide author information » Content type display: separate author and date information

It might be a good idea to just try to fix all the current tests that this braeks first. Doing that would give a good idea of how to go about setting up a couple of conditional tests.

Couple of comments:

+  $node_types = db_query('SELECT * FROM {node_type}')->fetchAllAssoc('type', PDO::FETCH_OBJ);

http://api.drupal.org/api/drupal/core--modules--node--node.module/functi...

+  if (!variable_get('node_submitted_date_' . $node->type) && !variable_get('node_submitted_author_' . $node->type)) {

Would probably be easier to read, and perhaps slightly more efficient to get each variable once before the if section.

+  } else {

else and ifelse go on a new line, according to coding standards.

Nice work so far, keen to see this in action!

naught101’s picture

cesar.brod@gmail.com’s picture

Subscribing!

naught101’s picture

You don't need to comment to subscribe. Please use the big green "follow" button at the top of the page.

jenlampton’s picture

+1 for separating these options, but I'd also love to see them on the manage display tab, as per
#1399990: Remove "Display author and date information" in Display Settings in favor of listing Author and Date in Manage Displays

yoroy’s picture

Issue tags: +Usability

Would be a nice little UX tweak that gives people more flexibility where they are likely to want it. Do it! :)

colan’s picture

Category: feature » support

The revisions tab should honour this as well. So, for example, if displaying author information is disabled, the author shouldn't show up in the revisions table (on the Revisions tab) either. See #1566082: Author is shown in Revisions table when "Display author and date information" is off.

colan’s picture

Category: support » feature

This is a new feature, not a support request.

rajat42059’s picture

Category: support » feature

You can download the module called submit by and then through this you can easily edit and format the information you want.

markhalliwell’s picture

Status: Needs work » Closed (duplicate)
surendra77c’s picture

Issue summary: View changes

In node.tpl.php write the below code to get the author name .

C:\xampp\htdocs\drupal7\themes\bartik\templates\node.tpl.php

  if ($node->type == 'article') {
 echo '<b>Authored by : </b>'; print($node->name);
}

print_r($node); // get list of all the variable like date , submitted date , author name , content type name etc .

numerabilis’s picture

Eu estava procurando colocar a data da última atualização também.
Estou usando Drupal 7 e o tema Pixture Reloaded.
Em algum lugar eu ví que tinha que alterar no tal de preprocess do node.

/**
 * Preprocess variables for node.tpl.php
 */
function adaptivetheme_preprocess_node(&$vars) {

No meu caso estava em:

/sites/all/themes/adaptivetheme/at_core/inc/preprocess.inc, line 732:

  // datetime stamp formatted correctly to ISO8601
  $vars['datetime'] = format_date($vars['created'], 'custom', 'd/m/Y \à\s H:i:s'); // PHP 'c' format is not proper ISO8601!

  // Publication date, formatted with time element
  $vars['publication_date'] = '<time datetime="' . $vars['datetime'] . '">' . $vars['date'] . '</time>';

  // Last update variables
  $vars['datetime_updated'] = format_date($vars['node']->changed, 'custom', 'd/m/Y \à\s H:i:s');
  $vars['custom_date_and_time'] = date('d/m/Y \à\s H:i:s', $vars['node']->changed);

  // Last updated formatted in time element
  $vars['last_update'] = '<time datetime="' . $vars['datetime_updated'] . '">' . $vars['custom_date_and_time'] . '</time>';

  // Build the submitted variable used by default in node templates
  if (variable_get('node_submitted_' . $vars['node']->type, TRUE)) {
    $vars['submitted'] = t('Enviado por !username em !datetime. Atualizado em !updated.',
      array(
        '!username' => $vars['name'],
        '!datetime' => $vars['publication_date'],
        '!updated'  => $vars['last_update'],
      )
    );
  }