Date Attribute formatting

Author Message

Hadi Jadallah

Thursday 05 February 2009 4:14:41 am

Hello

I have a class with an 'Object Name Pattern' that includes the publish date. So far, the Pattern looks like <title>-<publish_date>. The publish date is of type ezdate
Things are ok and working as expected when we publish content. For example we get something like:
GeneralUsageInfo-Sunday February 01 2009

My question is: how can I control the date format ezpublish uses to generate the object name? I would like the example to show up as:
GeneralUsageInfo-Feb-01-2009

If there are no ini setting that I can use to force the format in this case, can any one point me to code used to generate the object name when parsing the object name pattern?

Am running ez publish 4.0.1.

Thanks

Damien Pobel

Sunday 08 February 2009 3:12:49 pm

Hi

As far as I know, there is no settings to control the format of a date (or any other datatype) in the URL. The only way to do that is probably to write an extension providing an URL Alias filter. dpGNU [1] is a good example of such an extension (it adds the node id at the end of the URL), you can probably adapt it to your needs.

[1] http://ez.no/developer/contribs/applications/dpgnu_dp_google_news_url

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish

Hadi Jadallah

Monday 09 February 2009 4:53:15 am

Thanks Damien... Ill take a look to see if I can use the same technique.

Christoph von Siebenthal

Sunday 06 December 2009 12:38:31 am

Object Name Pattern uses DateTimeFormat= ... setting in share/locale/[yourlocale]

The options are the same as for the datetime operator

Of course you have to check if the modified DateTimeFormat doesn't destroy other views where it is used.

to change the datetime operator there could be necessary.

Comment:

Do we have to wait until version 10 for something like a SystemDateTimeFormat settings to be availlable?
And the possibility to extend locale with a ini.append.php technique?

It happens I found this on the ez forums at a time where the search results where ordered by descending publishing date.

It seems to me that be a priority to take this new forum from beta to CR stage.

And there needs to be a way to contribute without having to search during one hour what has or has not allready been noticed and discussed. I'm ready and motivated to share my answers to difficulties I found, by a can't afford to loose time in endless searching.

Christoph von Siebenthal

Tuesday 12 January 2010 11:27:57 am

Ok, since 4.2 it is DateFormat for Date date attribute. Of course that's more logical.

I didn't check if it is still DateTimeFormat for an DateTime attribute.

Carlos Revillo

Tuesday 12 January 2010 2:58:53 pm

you can also control the format doing a little hack. please correct me if i'm wrong.

if your date is datetime type, you can take a look at

kernel/classes/datatypes/ezdatetime/ezdatetimetype.php

There you'll find a function called title. Here's the code

function title( $contentObjectAttribute, $name = null )
{
 $locale = eZLocale::instance();
 $retVal
= $contentObjectAttribute->attribute( "data_int" ) == 0 ? '' :
$locale->formatDateTime( $contentObjectAttribute->attribute(
"data_int" ) );
 return $retVal;
}

you can modify that function and adjust $retVal to whatever you want.

Same goes for ezdate or eztime (or all of datatypes, i think)

if you prefer not to hack that file, you can create your own datatype, starting from the provided one.

Cheers.

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