Forums / General / Display article create date

Display article create date

Author Message

Steven Stieng

Friday 28 May 2010 8:35:34 am

I'm not able to display article create date.
My class consist of the following attributes:

  • Name
  • Intro
  • body
  • image 

 I'm fetching the articles using the following code:

{def $complaints=fetch('content', 'list', hash('parent_node_id', 75, 'limit', 5))}
<ul>
    {foreach $complaints as $complaint}
      <li>
        <a href={$complaint.path_identification_string|ezurl}>{$complaint.name|wash}</a> [{$complaint.data_map.published|l10n(date)}]
      </li>  
    {/foreach}  
</ul>

I'm able to list the names, but not the dates.

I've tried different variations:
{$complaint.data_map.published}
{$complaint.data_map.date_attribute_id.content.timestamp|l10n(date)}
{attribute_view_gui attribute=$complaint.data_map.date_attribute_id}
{$complaint.data_map.publication_date.content.timestamp|l10n(shortdatetime)}
What am I missing?

Gaetano Giunta

Friday 28 May 2010 10:39:25 am

You are missing the fact that the publication date is not an attribute of the object ;-)

In short: every content object, as available in the templates, is made up of:

  1. its attributes, as defined in the content class
  2. some extra metadata

For 1, you access them using $obj.data_map, and you can use them with attribute_view_gui

For 2, you access them directly: $obj.published, $obj.name etc...

Your best friend is the online doc: look at http://ez.no/doc/ez_publish/technical_manual/4_x/reference/objects/ezcontentobject - for every member of $obj listed the datatype is clearly indicated

(note: the manual page is not very clear in that it uses the term "attribute" to denote two different things; we have the same problem for newcomers trying to distinguish a 'content object' from a 'template object')

Principal Consultant International Business
Member of the Community Project Board

Håvard Bergersen

Friday 28 May 2010 11:13:50 pm

And just in case you don't know:

{$complaint|attribute(show)} Will tell you a lot.. :)

Steven Stieng

Wednesday 02 June 2010 12:37:13 am

Thanks for the reply guys. But none of you made any sense really :)
(sorry, I'm noob )

I am assuming the folloing:

1. Articles (also knows as objects) has some system attributes. One being the creation date.

2. I do not need to create a date attribute for the class, since this is recorded automatically (one should never have to manually enter creation date of an article)

If you look at my example above, you will see that I am using 'attribute_view_gui' and 'data_map'.
I'm also using Håvards suggestions to output information about whatever object I have in my $complaint variable using

{$article|attribute(show, 1)}
{$article.data_map|attribute(show, 1)}

Can anyone give me an example of the code I need to use?

Steven E. Bailey

Wednesday 02 June 2010 2:56:15 am

try {$complaint.object.published|datetime}

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Steven Stieng

Wednesday 02 June 2010 3:13:00 am

Oh, great! Thanks! Also using {$complaint.object|attribute(show, 1)} shows be all the attributes of the object. 

Now, can you tell me why the publish date is formatted like this?

1275052797, 1275052846, 1275052903

They don't really look like dates to me :) 

Steven E. Bailey

Wednesday 02 June 2010 4:03:42 am

Unix time. That's what the datetime operator was for in the above example.

http://ez.no/doc/ez_publish/technical_manual/4_x/reference/template_operators/formatting_and_internationalization/datetime

try {$complaint.object.published|datetime( 'custom', '%h:%i %a %d %F %Y' )}

Certified eZPublish developer
http://ez.no/certification/verify/396111

Available for ezpublish troubleshooting, hosting and custom extension development: http://www.leidentech.com

Steven Stieng

Wednesday 02 June 2010 4:14:15 am

Aha!
I've never seen UNIX time before (as I can recall)
Thank you very much! 

Sujit Sth

Tuesday 04 January 2011 8:23:03 pm

Hi,

For published date of an article:

{$node.object.published|l10n(date)}

for all other date format click link below:

http://blog.developeronhire.com/tag/published-date/

Thank you

eZ debug

Timing: Jan 15 2025 07:10:09
Script start
Timing: Jan 15 2025 07:10:09
Module start 'content'
Timing: Jan 15 2025 07:10:10
Module end 'content'
Timing: Jan 15 2025 07:10:11
Script end

Main resources:

Total runtime1.4729 sec
Peak memory usage6,144.0000 KB
Database Queries211

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0072 684.1406214.8047
Module start 'content' 0.00721.2772 898.94532,036.4063
Module end 'content' 1.28450.1884 2,935.3516638.8750
Script end 1.4728  3,574.2266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00710.4829210.0003
Check MTime0.00160.1062210.0001
Mysql Total
Database connection0.00100.065010.0010
Mysqli_queries1.350591.69272110.0064
Looping result0.00220.15062080.0000
Template Total1.441997.920.7209
Template load0.00420.286020.0021
Template processing1.437697.605520.7188
Template load and register function0.00120.081710.0012
states
state_id_array0.00060.043610.0006
state_identifier_array0.00110.072620.0005
Override
Cache load0.00400.2710910.0000
Sytem overhead
Fetch class attribute can translate value0.00130.088560.0002
Fetch class attribute name0.00220.1514130.0002
XML
Image XML parsing0.00410.275460.0007
class_abstraction
Instantiating content class attribute0.00000.0013140.0000
General
dbfile0.00300.2026400.0001
String conversion0.00000.000430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
16content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/li.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/li.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ul.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ul.tplEdit templateOverride template
12content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/ol.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/ol.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 62
 Number of unique templates used: 11

Time used to render debug report: 0.0001 secs