Forums / Setup & design / Date Attribute formatting

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.

eZ debug

Timing: Jan 18 2025 03:12:27
Script start
Timing: Jan 18 2025 03:12:27
Module start 'content'
Timing: Jan 18 2025 03:12:28
Module end 'content'
Timing: Jan 18 2025 03:12:28
Script end

Main resources:

Total runtime1.1790 sec
Peak memory usage4,096.0000 KB
Database Queries207

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 588.8438180.8359
Module start 'content' 0.00631.0393 769.6797659.1328
Module end 'content' 1.04560.1333 1,428.8125341.0625
Script end 1.1789  1,769.8750 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.3700210.0002
Check MTime0.00150.1277210.0001
Mysql Total
Database connection0.00100.086310.0010
Mysqli_queries1.100593.34502070.0053
Looping result0.00220.18442050.0000
Template Total1.144897.120.5724
Template load0.00220.190520.0011
Template processing1.142696.908820.5713
Template load and register function0.00010.011510.0001
states
state_id_array0.00120.102510.0012
state_identifier_array0.00140.121020.0007
Override
Cache load0.00200.1669450.0000
Sytem overhead
Fetch class attribute can translate value0.00200.173550.0004
Fetch class attribute name0.00150.124280.0002
XML
Image XML parsing0.00150.125850.0003
class_abstraction
Instantiating content class attribute0.00000.004090.0000
General
dbfile0.00250.2101330.0001
String conversion0.00000.000330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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