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

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 18 2025 02:06:48
Script start
Timing: Jan 18 2025 02:06:48
Module start 'layout'
Timing: Jan 18 2025 02:06:48
Module start 'content'
Timing: Jan 18 2025 02:06:49
Module end 'content'
Timing: Jan 18 2025 02:06:49
Script end

Main resources:

Total runtime0.7911 sec
Peak memory usage4,096.0000 KB
Database Queries81

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 589.0391152.6250
Module start 'layout' 0.00620.0030 741.664139.4453
Module start 'content' 0.00930.7803 781.1094752.7422
Module end 'content' 0.78960.0015 1,533.851620.1641
Script end 0.7911  1,554.0156 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4222160.0002
Check MTime0.00140.1709160.0001
Mysql Total
Database connection0.00090.113110.0009
Mysqli_queries0.707289.3850810.0087
Looping result0.00080.0997790.0000
Template Total0.759195.920.3795
Template load0.00190.235220.0009
Template processing0.757295.708620.3786
Template load and register function0.00010.015910.0001
states
state_id_array0.00090.114310.0009
state_identifier_array0.00160.205020.0008
Override
Cache load0.00170.2102910.0000
Sytem overhead
Fetch class attribute can translate value0.00060.076350.0001
Fetch class attribute name0.00140.1727130.0001
XML
Image XML parsing0.00350.444850.0007
class_abstraction
Instantiating content class attribute0.00000.0029140.0000
General
dbfile0.00250.3190350.0001
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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