Forums / Setup & design / Correct date format in a class pattern. HOW?

Correct date format in a class pattern. HOW?

Author Message

PaoloMellerio kk

Wednesday 04 June 2003 12:40:25 am

Hi,
I 've made a new class for storing some news: its name is MyNews; in it, among the others, there are two Attributes: Title and Date.
The problem is to create a particular "Object name pattern" for the class MyNews, so that in the list of MyNews in the Folder which contains them in the Admin page, i can see listed the news seeing their title and date, I.E.: MyNewsTitle, MyNewsDate. I've tried with a pattern such <title>, <data>, but in the admin I see them in a way like this: MyNewsTitle, 1054677600. It's ok for the title, but not for the date which seems to be shown in a "serial" way. The question is: is there a way to apply a particular format to Date Attribute in the "Object name pattern" for the class MyNews, so I see them listed in the way: MyNewsTitle, 04.06.03.
If Yes, How?
Thanks in advice.
Paolo Mellerio (Clikka.com)

Paolo Mellerio
http://www.clikka.com

Dan Zembrosky

Wednesday 04 June 2003 10:30:35 pm

just got to this problem too, please help, I want to call the day, the month and the year all seperatly because of the way my site designed.

Frode Marton Meling

Wednesday 04 June 2003 11:49:22 pm

I believe it is not possible to do this just in the Object Name pattern. You have to make an override template for the class you created. When you do that you can use a template operator called datetime.

Example:
You have created a class with ID 20.
You then create a template called line_class_20.tpl inside the ...design\<yoursiteaccess>\override\templates\node\view folder (in ver3.1b you also need to update the override.ini.append file)
Then you insert something like this inside the template file:
...
{default node_name=$node.name}
<a href={concat('content/view/full/',$node.node_id)|ezurl}>
$node_name|wash}</a>
{/default}
<i> (Last edited: {$node.object.modified|datetime(custom,"%d/%m-%y %h:%i")})</i>
...
Everytime the class is listed in line view, this template will override the default presentation for the class.

Here you see how I use the datetime operator.
For more info look in the ezSDK. For more info on the datetime format-strings ("%d/%m") look at php homepage.

MartOn