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.

eZ debug

Timing: Jan 18 2025 10:41:50
Script start
Timing: Jan 18 2025 10:41:50
Module start 'layout'
Timing: Jan 18 2025 10:41:50
Module start 'content'
Timing: Jan 18 2025 10:41:52
Module end 'content'
Timing: Jan 18 2025 10:41:52
Script end

Main resources:

Total runtime1.9071 sec
Peak memory usage4,096.0000 KB
Database Queries70

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0079 587.9141152.6250
Module start 'layout' 0.00790.0065 740.539139.4453
Module start 'content' 0.01451.8910 779.9844654.0547
Module end 'content' 1.90540.0017 1,434.039116.1641
Script end 1.9071  1,450.2031 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.2117160.0003
Check MTime0.00150.0790160.0001
Mysql Total
Database connection0.00100.053510.0010
Mysqli_queries1.837596.3503700.0263
Looping result0.00100.0505680.0000
Template Total1.848896.920.9244
Template load0.00220.116520.0011
Template processing1.846696.827020.9233
Template load and register function0.00010.005910.0001
states
state_id_array0.00210.112510.0021
state_identifier_array0.00290.153120.0015
Override
Cache load0.00200.1023450.0000
Sytem overhead
Fetch class attribute can translate value0.00060.031740.0002
Fetch class attribute name0.00140.071780.0002
XML
Image XML parsing0.00110.056240.0003
class_abstraction
Instantiating content class attribute0.00000.001190.0000
General
dbfile0.00090.0498220.0000
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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs