Formating date in news archive and news archive menu
Hi,
How can I change these date formats in right way? (monthly format)
- title(headline) of news archive[/*:m:3fyl8a97]
- title of news archive menu's each item[/*:m:3fyl8a97]
In the case of news archive, headline's format come from line 125 of system/modules/news/ModuleNewsArchive.php:
Code:
$this->headline .= ' ' . $this->parseDate('F Y', $objDate->tstamp);
And "F" is finally converted using $GLOBALS['TL_LANG']['MONTHS'] and "Y" is simply 4-digit year.
In Japanese, day, month and year are represented by numeric number and units name like "1m = 1 meter".
And order of dates are year -> month [-> day]. (Except representation of month in ancient writing.)
So I want to represents in "2010-nen 8-gatsu". (Really, "-nen" and "-gatsu" are represented in one Kanji
character and there is no space in total string.)
- How can I change these "month year" to "year month" style? I know modifying template could solve the problem but it would be complex for using the templates by many languages.[/*:m:3fyl8a97]
- Where can I get units of day and year? In the case of month, $GLOBALS['TL_LANG']['MONTHS'] contains already digit and units character.[/*:m:3fyl8a97]
Best regards.
Re: Formating date in news archive and news archive menu
After thinking by myself, I think we need one more setting of date/time format.
Currently, there are three date/time formats:
Code:
$GLOBALS['TL_CONFIG']['datimFormat'] = 'Y-m-d H:i';
$GLOBALS['TL_CONFIG']['dateFormat'] = 'Y-m-d';
$GLOBALS['TL_CONFIG']['timeFormat'] = 'H:i';
For localized headline, "month year" format of news archive or news archive menu,
Code:
$GLOBALS['TL_CONFIG']['monthyearFormat'] = "F Y";
$GLOBALS['TL_CONFIG']['yearFormat'] = "Y";
Lastly, calendar/ModuleEventlist.php and news/ModuleNewsArchive.php use these formats
instead of hard coding "F Y" and "Y".
So, I could change them in root page's setting which results:
Code:
$GLOBALS['TL_CONFIG']['monthyearFormat'] = "Y?n?";
$GLOBALS['TL_CONFIG']['yearFormat'] = "Y?";
Re: Formating date in news archive and news archive menu
After all, I created some changes against Contao 2.9.1.
Basically, I added three new variables to a language file of backend, default.php:
Code:
$GLOBALS['TL_LANG']['MSC']['yearSuffix'] = '';
$GLOBALS['TL_LANG']['MSC']['monthyearOrder'] = 1;
$GLOBALS['TL_LANG']['MSC']['wdayLetterCount'] = 2;
In Japanese version:
Code:
$GLOBALS['TL_LANG']['MSC']['yearSuffix'] = '?';
$GLOBALS['TL_LANG']['MSC']['monthyearOrder'] = 0;
$GLOBALS['TL_LANG']['MSC']['wdayLetterCount'] = 1;
- 'yearSuffix' adds suffix (or units) for year.[/*:m:1h2bmhlr]
- 'monthyearOrder' define order of "month" and "year".[/*:m:1h2bmhlr]
- 'wdayLetterCount' is number of letter to be used for week of day in mini calendar.[/*:m:1h2bmhlr]
Attached zip file contains patch for these files. (Oops, library/Date.php isn't need to be changed
and it contains some trial code...)
Code:
libraries/Date.php
modules/backend/languages/en/default.php
modules/backend/languages/ja/default.php
modules/calendar/Events.php
modules/calendar/ModuleCalendar.php
modules/calendar/ModuleEventMenu.php
modules/calendar/ModuleEventlist.php
modules/calendar/templates/cal_mini.tpl
modules/calendar/templates/mod_eventmenu.tpl
modules/frontend/Module.php
modules/news/ModuleNewsArchive.php
modules/news/ModuleNewsMenu.php
modules/news/templates/mod_newsmenu.tpl
modules/news/templates/mod_newsmenu_day.tpl
Best regards.