"Article published by and last updated by"-snippet

Author Message

Valentin Svelland

Tuesday 11 November 2003 3:21:49 am

At the end of every article of my site I'd like to show some information about when the article was published and by whom. Also, if the article is updated I'd like to show the same information for the last update.

I haven't spent to much time on this, and as I'm sure somebody already must have faced and probably solved this situation, I hoping for some solutions here on the forum.

This is my pesudocode; of course it doesn't work properly. It needs a section show to hide the "last updated"-part if the article hasn't been updated.

{default content_object=$node.object}

<p class="byline">

By: {$node.original_creator.name}, {$content_object.published|l10n( datetime )}

<section show=(if altered=true)>
<br />Modified by: {$node.new_creator.name},{$content_object.modified|l10n(datetime)}
</section>

</p>

It's important that changes made by a second editor user doesn't overwrite the original creators name after "Published by", but is placed after "Modified by:".

Yup, any suggestions is much appreciated.
Regards, Valentin.

By the way; I posted this related topic earlier this year:
http://www.ez.no/developer/ez_publish_3/forum/setup_design/is_the_original_authors_name_overwritten_

Shurbann Martes

Tuesday 11 November 2003 6:00:20 am

Hello Valentin,

This code should work, but I haven;t test it. Check the comments for explanation

{default content_object=$node.object //original article
content_version=$node.contentobject_version_object} //latest version of article

<p class="byline">

Posted By: {$content_object.owner.name|wash}, //show owner of the original article
{$content_object.published|l10n(datetime)} //show datetime of original article

{section name=modified show=and($content_object.is_published|not(), $content_version|eq(1)} //check if original is not_published (value: "0") and if the status of the latest version is "1", if both are true show section

<br />Modified by: {$content_version.creator.name} //name of creator of the latest version, {$content_version.modified|l10n(datetime)} //datetime of the latest version
</section>

</p>

I don't know if checking for the published value of the original is enough, that's why I'm checking for the status of the latest version too (I think value "1" means everything is fine, and that it is published)

Good luck,
Shurbann

Valentin Svelland

Thursday 13 November 2003 1:09:18 am

Thanks shurbann, your reply was very useful. I've tested it out, made some small changes - and yes - it works!!

Everyone, feel free to use this snippet:
-------------------------------------

{default content_object=$node.object
content_version=$node.contentobject_version_object}

<p class="byline">

Published by: {$content_object.owner.name|wash}, {$content_object.published|l10n(datetime)}

{section name=modified show=and($content_object.is_published|not(), $node.contentobject_version_object.version|gt(1))}

<br />Last modified by: {$content_version.creator.name}, {$content_version.modified|l10n(datetime)}

{/section}

</p>

-------------------
Good luck! :)

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 04:25:27
Script start
Timing: Jan 31 2025 04:25:27
Module start 'layout'
Timing: Jan 31 2025 04:25:27
Module start 'content'
Timing: Jan 31 2025 04:25:27
Module end 'content'
Timing: Jan 31 2025 04:25:27
Script end

Main resources:

Total runtime0.0153 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 588.2813151.2266
Module start 'layout' 0.00610.0035 739.507836.6797
Module start 'content' 0.00960.0042 776.187594.1875
Module end 'content' 0.01380.0015 870.375033.9922
Script end 0.0153  904.3672 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002516.5195140.0002
Check MTime0.00127.5637140.0001
Mysql Total
Database connection0.00074.878910.0007
Mysqli_queries0.003522.887230.0012
Looping result0.00000.137010.0000
Template Total0.00117.310.0011
Template load0.00085.165510.0008
Template processing0.00032.128810.0003
Override
Cache load0.00053.234410.0005
General
dbfile0.00031.913980.0000
String conversion0.00000.071640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs