Forums / Developer / Display a date datatype

Display a date datatype

Author Message

Roberta Gatti

Friday 05 March 2004 1:49:13 am

hi,
I create a new class with the date field (yyy/mm/dd)... when I use a fetch function to display the data {$:item.data1} I can't see the date field and appear an error "Object(ezcontentobjectattribute)"

What is the problem?

TIA
R.

Trond Åge Kvalø

Friday 05 March 2004 2:33:27 am

Hello Roberta!

Maybe some of the info in this thread might help?

http://www.ez.no/community/forum/setup_design/date_format

best regards
trondåge

trondåge

Roberta Gatti

Friday 05 March 2004 3:03:44 am

Hi,
I read this topic but this is my code:

{let children=fetch('content','list',hash(parent_node_id,72))
sub_children_count=fetch(content,list_count,hash(parent_node_id,72))}

{section name=Child loop=$:children max=2}
<tr valign="top">
<td>{$:item.data1.content}</td>
<td colspan="2"><a href={concat('content/view/full/',$:item.node_id)|ezurl}>{$:item.data_map.title.content}<br/></a></td>
</tr>
{/section}
{/let}

<td>{$:item.data_map.data1.content}</td> don't appear

I try to use <td>{$:item.data_map.data1.content}</td>

The error now is "Object(ezdate)"

Why?

TIA
R.

Trond Åge Kvalø

Friday 05 March 2004 3:15:41 am

Hi Roberta!

Try this code:

<td>{$:item.data_map.data1.data_int|datetime(custom,"%Y/%m/%d")}</td>

Hope this helps
trondåge

trondåge

Roberta Gatti

Friday 05 March 2004 3:31:43 am

now the date appears

Thank you !!!!

R.

Trond Åge Kvalø

Friday 05 March 2004 4:04:04 am

Excellent!

Now if you want to use other formats on your date you can use the codes found in this page:

http://www.ez.no/ez_publish/documentation/customization/tips_tricks/date_and_time_formats

Let's say that you for instance want to show your date as Friday 5. March 2004 then you'd use the following code:

<td>{$:item.data_map.data1.data_int|datetime(custom,"%l %j. %F %Y")}</td>

best regards
trondåge

trondåge

Roberta Gatti

Friday 05 March 2004 7:49:39 am

Ok,
but now I have another problem .... using fetch function I want to order the results by date field (data1)

{let children=fetch('content','list',hash(parent_node_id,72,
sort_by, data1 )) }

but it daesn't work, why?
TIA
R.

Trond Åge Kvalø

Sunday 07 March 2004 1:31:26 pm

The sort_by parameter should be an array.

Try this:

{let children=fetch('content','list',hash(parent_node_id,72,
sort_by, array('data1', false())))}

And hopefully your data should be sorted with the most recent element at the top.

hth
trondåge

trondåge

Roberta Gatti

Monday 08 March 2004 7:16:51 am

Hi,
unfortunately your code produces a blank line. I don't find a right code.

:-((

R.

Alex Jones

Monday 08 March 2004 7:29:33 am

Try

{let children=fetch('content','list',hash(parent_node_id,72,
                                          sort_by,array(array('attribute',false(),'data1'))))}

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Roberta Gatti

Monday 08 March 2004 7:32:04 am

Don't work.

Bruce Morrison

Monday 08 March 2004 3:26:00 pm

Hi Roberta

See http://ez.no/ez_publish/documentation/reference/data_fetching/content/list

Also turn on debugging. This will give some error messages that will either lead you the the answer or help people in the list solve the issue.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Trond Åge Kvalø

Tuesday 09 March 2004 12:15:01 am

Hi Roberta!

I'm new at this as well, and my earlier post was not entirely correct. According to the link:

http://ez.no/ez_publish/documentation/reference/data_fetching/content/list

I believe this would do it though

{let children=fetch('content','list',hash(parent_node_id,72,
                                          sort_by,array('attribute',false(),'data1')))}

If that doesn't work, you should turn on debugging and see if there are any error messages.

hth
trondåge

trondåge

Roberta Gatti

Tuesday 09 March 2004 7:52:56 am

It doesn't work .... how can I turn on debugging to try error?

R.

Trond Åge Kvalø

Tuesday 09 March 2004 9:27:15 am

In your site.ini.append file, insert the following lines:

[DebugSettings]
DebugOutput=enabled

This will show the debug output beneath your page

best regards
trondåge

trondåge

Roberta Gatti

Wednesday 10 March 2004 2:13:40 am

An error appears, but I don't know what it means:

Error: eZMySQLDB Mar 10 2004 11:11:06
Query error: You have an error in your SQL syntax near 'AND
a0.version = ezcontentobject_name.conten' at line 18. Query: SELECT ezcontentobject.*,
ezcontentobject_tree.*,
ezcontentclass.name as class_name

, ezcontentobject_name.name as name, ezcontentobject_name.real_translation
FROM
ezcontentobject_tree,
ezcontentobject,ezcontentclass
, ezcontentobject_name
, ezcontentobject_attribute as a0


WHERE
path_string like '/1/2/72/%' and depth <= 3 and


a0.contentobject_id = ezcontentobject.id AND
a0.contentclassattribute_id = AND
a0.version = ezcontentobject_name.content_version AND
a0.language_code = ezcontentobject_name.real_translation AND

ezcontentclass.version=0 AND
node_id != 72 AND
ezcontentobject_tree.contentobject_id = ezcontentobject.id AND
ezcontentclass.id = ezcontentobject.contentclass_id AND

ezcontentobject_tree.contentobject_is_published = 1
and ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id and
ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version and
ezcontentobject_name.content_translation = 'ita-IT'

ORDER BY a0.sort_key_int DESC
Notice: eZMySQLDB::query(0.000 ms) query number per page:0 Mar 10 2004 11:11:06
SELECT ezcontentobject.*,
ezcontentobject_tree.*,
ezcontentclass.name as class_name

, ezcontentobject_name.name as name, ezcontentobject_name.real_translation
FROM
ezcontentobject_tree,
ezcontentobject,ezcontentclass
, ezcontentobject_name
, ezcontentobject_attribute as a0


WHERE
path_string like '/1/2/72/%' and depth <= 3 and


a0.contentobject_id = ezcontentobject.id AND
a0.contentclassattribute_id = AND
a0.version = ezcontentobject_name.content_version AND
a0.language_code = ezcontentobject_name.real_translation AND

ezcontentclass.version=0 AND
node_id != 72 AND
ezcontentobject_tree.contentobject_id = ezcontentobject.id AND
ezcontentclass.id = ezcontentobject.contentclass_id AND

ezcontentobject_tree.contentobject_is_published = 1
and ezcontentobject_tree.contentobject_id = ezcontentobject_name.contentobject_id and
ezcontentobject_tree.contentobject_version = ezcontentobject_name.content_version and
ezcontentobject_name.content_translation = 'ita-IT'

ORDER BY a0.sort_key_int DESC

Trond Åge Kvalø

Thursday 11 March 2004 1:57:51 am

The error appears because the line

a0.contentclassattribute_id = AND

is missing a contentclassattribute_id after the equals character

And the reason for this is that the attribute 'data1' in

{let children=fetch('content','list',hash(parent_node_id,72,
                                          sort_by,array('attribute',false(),'data1')))}

doesn't return the contentclassattribute_id. What you should try to do is to find the contentobjectatribute_id of 'data1' manually, and insert that instead of 'data1' in the sort_by expression.

You'll find the contentobjectattribute_id by editing your class. In the attributes list the attributes are listed by number, name, datatype and id. The id is the needed contentobjectattribute_id.

Try this an see if that helps.

best regards
trondåge

trondåge

Roberta Gatti

Friday 12 March 2004 12:37:26 am

Hi,
thank you very much for your precious help!!

Roberta
;-))))

Trond Åge Kvalø

Friday 12 March 2004 1:54:34 am

> ;-))))

I presume this means that it worked? :-)

trondåge

trondåge