What's wrong ? 70's

Author Message

laurent le cadet

Thursday 21 April 2005 1:19:45 am

Hi,

I added a empty datefield to the article class to allowed users to change the publication date.
In article.tpl I wrote this :

{section show=$node.object.data_map.date_de_publication.content.is_empty|not()}
{$node.object.data_map.date_de_publication.data_int|datetime(custom,"%F %Y")}
{section-else}
{$node.object.published|datetime(custom,"%F %Y")}
{/section}

So if users leave it blank we use the publication's date.

but this :

{$node.object.published|datetime(custom,"%F %Y")}

nested in {section-else} print January 1970.

When this part of the code is out of the section block I have the good date.

Any hint ?

Laurent

Łukasz Serwatka

Tuesday 26 April 2005 6:45:20 am

Hi Laurent,

Try with

{$node.object.published|datetime('custom', '%F %Y')}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

laurent le cadet

Tuesday 26 April 2005 7:00:02 am

Hi Lukasz,

january 1970 :(
It seems to be simple but I have no idea about that.

Łukasz Serwatka

Tuesday 26 April 2005 7:04:52 am

Try without section, just for current node

{$node.object.published|datetime('custom', '%F %Y')}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Hans Melis

Tuesday 26 April 2005 7:06:23 am

Let's try to locate the error first.

What is printed when you only do {$node.object.published} in the section-else?

If it doesn't print 0, the error is in the datetime operator. But my wild guess is that it will print 0.

Hans
http://blog.hansmelis.be

laurent le cadet

Tuesday 26 April 2005 7:22:59 am

I tryed both of your hints :

{section show=$node.object.data_map.date_de_publication.content.is_empty|not()}
- {$node.object.data_map.date_de_publication.data_int|datetime(custom,"%F %Y")}
{section-else}
- {$node.object.published}
{/section}
{$node.object.published|datetime('custom',"%F %Y")}

{$node.object.published} = january 1970
{$node.object.published|datetime('custom',"%F %Y")}= august 2002

laurent le cadet

Monday 16 May 2005 12:37:15 am

Solved

I removed the attribute "date_de_pubication" and create a new one (empty by default) and it's ok.

I think the mistake (bug ?) was that when I created it first I made it with "today's date" by default and then changed to leave it empty.
The first choice seems to take advantage on the second.

Here's the code if it can help someone :

{section show=$node.object.data_map.date_de_publication.has_content}
{$node.object.data_map.date_de_publication.data_int|datetime(custom,"%F %Y")}
{section-else}
{$node.object.published|datetime('custom',"%F %Y")}
{/section}

Laurent

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