It would be nice to be able to toggle on/off a "last edited on _date_" tag to the end of the "submitted by _user_ on _date_" line at the top of nodes. Somewhere I found a hack for adding this (though not as a configurable option) to xtemplate themes, and recently adapted it to work with PHPTemplate. I'm not really a programmer and don't know how to do patch submissions, but here is what you need to change on the phptemplate.engine file:

1) Beginning around line 280 under "function phptemplate_node" insert this:

$last_edited = '';

if ($node->created != $node->changed)
{
$last_edited = t(' | Last edited on %a',
array('%a' => format_date($node->changed)));
}

2) Then just below the newly inserted code, change this:

$vars['submitted'] = t('Submitted by %a on %b.', array('%a' => format_name($node), '%b' => format_date($node->created)));
}

to this:

$vars['submitted'] = t('Submitted by %a on %b.', array('%a' => format_name($node), '%b' => format_date($node->created))) . $last_edited;
}

3) Voila! If your node has been edited after its original submission date, the submission line should now include a "last edited on _date_" segment.

Unfortunately, I couldn't find where I found this original hack for Xtemplate, so I can't credit the source. It required only slight modifications to work with PHPTemplate.

It would be nice to have this built into PHPTemplate as an option that could be toggled on or off via the theme config page.

Comments

morbus iff’s picture

Project: PHPTemplate » Drupal core
Version: » x.y.z
Component: Code » theme system

PHPTemplate is part of core in 4.7. Moving.

shouchen’s picture

Status: Active » Needs review
StatusFileSize
new3.67 KB

Here is a patch that accomplishes everything you asked for, including the ability to toggle on and off the display of the "Last revised" time. I changed the term from "Last edited" to "Last revised" because the $node->changed is only updated when you create a new revision.

This is my first Drupal patch that actually changes the way the code functions. Take it easy on me....

-Steve

shouchen’s picture

StatusFileSize
new8.23 KB

Screen shot because of change to GUI

shouchen’s picture

StatusFileSize
new3.67 KB

Updated patch because system.module changed slightly today in HEAD.

shouchen’s picture

Could this be considered for 4.7? The changes are very simple.

shouchen’s picture

StatusFileSize
new2.26 KB

Updated patch

rkerr’s picture

I'd like to see this feature. Haven't tested the patch myself yet though :)

shouchen’s picture

StatusFileSize
new3.67 KB

PLEASE USE THIS PATCH INSTEAD OF THE ONE I UPLOADED A FEW MINUTES AGO

shouchen’s picture

Drupal Developers,
Could we get this very simple, yet useful, feature into 4.7 before the release candidate is released and it is too late for new features?
Thanks... -Steve

shouchen’s picture

StatusFileSize
new3.99 KB

Updated patch to include recent change to node.module

shouchen’s picture

shouchen’s picture

StatusFileSize
new3.84 KB

Cleaner code in the modification to node.module

shouchen’s picture

StatusFileSize
new2.98 KB

Modification to node.module no longer needed, already committed to HEAD because of http://drupal.org/node/41973

Tobias Maier’s picture

Status: Needs review » Needs work

I reviewed your code a little bit

here are my thoughts:

  • I dont like this part
    +
    +  $last_revised = '';
    +
    +  if (theme_get_setting('toggle_revision_info_' . $node->type) && ($node->changed != 0) && ($node->created != $node->changed))
    +  {
    +    $last_revised = t(' | Last revised on %a.',
    +    array('%a' => format_date($node->changed)));
    +  } 
    

    do it the way it is done for $taxonomy (under this piece of code)
    means with else {}
    looks better and is clearner

  • the ugliest thing is that: $last_revised = t(' | Last revised on %a.',
    fist | is something which belongs to a theme
    second what if I want to print the "last revised"-part on another place as the submitted-variable?
    It would be much cleaner if you would insert a new variable
shouchen’s picture

StatusFileSize
new4.16 KB

Tobias,
I think I understand what you mean... please review my latest patch.
Thanks,
Steve

shouchen’s picture

Status: Needs work » Needs review
shouchen’s picture

This is only supported for PHPTemplate themes, but the options are displayed for all themes. Is that an issue? If so, how do I get around that?

shouchen’s picture

Status: Needs review » Needs work

Should be easy enough to add to chameleon (XTemplate) theme... I'll work on that.

shouchen’s picture

Status: Needs work » Needs review
StatusFileSize
new5.9 KB

Now the patch also works with the chameleon theme. Please review... thanks!

shouchen’s picture

Requesting code review, please. I think I've made all of the suggested changes. Thanks!

Crell’s picture

Status: Needs review » Reviewed & tested by the community

Applies cleanly for me, does what it claims, doesn't seem to break anything for me. Sending this upstairs to the big people. :-)

shouchen’s picture

Looks like the big people upstairs might not have noticed the delivery... :-)

shouchen’s picture

Please consider this contribution for 4.7 -- thank you.

JPV’s picture

Please consider adding this to 4.7! The lack of this drives me nuts (http://drupal.org/node/28434). I could not possibly care less when a node was created, I want to know the last time somone maintained (edited) it. I can't believe something so fundamantal is missing from such a great product. Am I just missing something? This patch seems to show I'm not, but...

shouchen’s picture

StatusFileSize
new5.94 KB

Updated patch file because of some recent changes to applicable files.

shouchen’s picture

Please consider this feature for 4.7... thanks.

drumm’s picture

Status: Reviewed & tested by the community » Needs work

I think the current "Display post information on" is more readable than "Post submission information display." The new setting should have a simple title to match.

Otherwise looks okay.

And it is not necessary to add useless comments every week.

shouchen’s picture

Status: Needs work » Needs review
StatusFileSize
new5.31 KB

drumm,

The code in system.module had changed somewhat since I first created the patch. I've updated the patch so it can be applied to the current CVS HEAD cleanly (and to DRUPAL-4-7 with some "fuzz" and "offsets"). I've also changed some of the wording per your suggestion. Please review - thanks! -Steve

Crell’s picture

Version: x.y.z » 6.x-dev
Status: Needs review » Needs work

I'm fairly certain a patch this old would need to be redone, but I'd still like to see it make it in.

Freso’s picture

Subscribing as I'll happily review the code when it gets updated, but I don't see meself having the time for this soonishly.

pancho’s picture

Version: 6.x-dev » 7.x-dev

Damn, this would have been great! Still it's too late for new features. Let's make D7 the best Drupal ever... :)

lhtown’s picture

Oh, I do hope something like this is going into Drupal 7! The ability to change "submitted on" to "last updated on" would be perfectly marvelous.

sun.core’s picture

Version: 7.x-dev » 8.x-dev
valthebald’s picture

1. Probably current setting should be split to 3, not 2:
a) Display author
b) Display created date
c) Display updated date
2. Should variable_get() be replaced with CMI configuration?

joelpittet’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Needs work » Closed (works as designed)

This can be done using the theme_settings toggle still in D8. Very similar to the last patch.

Your node.html.twig template.

    {{ node.changedtime }}<br>
    {{ node.changedtime|format_date('small') }}<br>
    {{ 'Last revised at @date'|t({ '@date': node.changedtime|format_date('short') }) }}<br>

If you feel this feature would be helpful still please re-open for 8.1.x feature but I think we have enough that if this is needed contrib or custom module/theme could solve this in a snap.