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 29 2025 13:35:40
Script start
Timing: Jan 29 2025 13:35:40
Module start 'content'
Timing: Jan 29 2025 13:35:40
Module end 'content'
Timing: Jan 29 2025 13:35:40
Script end

Main resources:

Total runtime0.1265 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 587.9219180.8438
Module start 'content' 0.00480.0057 768.7656106.6172
Module end 'content' 0.01050.1159 875.3828536.2734
Script end 0.1264  1,411.6563 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00332.5873200.0002
Check MTime0.00131.0593200.0001
Mysql Total
Database connection0.00060.468710.0006
Mysqli_queries0.085467.48641410.0006
Looping result0.00110.88621390.0000
Template Total0.115691.410.1156
Template load0.00080.652910.0008
Template processing0.114890.730410.1148
Override
Cache load0.00060.472710.0006
Sytem overhead
Fetch class attribute can translate value0.00060.457110.0006
XML
Image XML parsing0.00020.174010.0002
General
dbfile0.00645.0200200.0003
String conversion0.00000.004930.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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