This was making me insane, but I learned a couple of things about Joomla in the process.
So I’m using the Blog layout for a Category of Joomla content. (Yes, I realize Wordpress is a better tool for blogging. Stay with me here.)
By default, the dates displayed with each article title look like this:
Sunday, 29 March, 2009 17:44copy code
I mean, that’s great: if you’re British.
The first thing that baffled me was the composition of the templates in com_content. Looks like this (in com_content/views/category/blog.php)
for ($z = 0; $z < $this->params->get('num_columns'); $z ++) : if ($z > 0) : $divider = " column_separator"; endif; ?> params->get('num_intro_articles') / $this->params->get('num_columns')); $y ++) : if ($i < $this->total && $i < ($numIntroArticles)) : $this->item =& $this->getItem($i, $this->params); echo $this->loadTemplate('item'); $i ++; endif; endfor;copy code
For the life of me, I couldn’t figure out what $this->loadTemplate(’item’) did (mostly because the patTemplate API is buried beneath the Joomla API, and because PHP toolsets just aren’t sophisticated enough yet. But I digress).
Google revealed that when you call $this->loadTemplate(String) from within a Joomla template file, the presentation framework looks for a file named “<template>_<name>.php” where <template> is the name of the current template file (in this case, “blog”) and <name> is the value passed to the loadTemplate method.
So then, in com_content/views/category/blog_item.php, I found this bit of obscurity
echo JHTML::_('date', $this->item->created, JText::_('DATE_FORMAT_LC2'));copy code
Fortunately, this one was easier to follow, but in the end, I still had to use Google to discover that DATE_FORMAT_LC2 is a reference from Joomla’s implementation of internationalization. Internationalization is configured with the files stored in the language folder. At this point, the correct way to fix my problem would have been to create a new language zone (e.g., en-US), but instead I decided just to amend the existing source.
In the file language/en-GB/en-GB.ini, you’ll find a series of definitions looking something like this
DATE_FORMAT_LC=%A, %d %B %Y DATE_FORMAT_LC1=%A, %d %B %Y DATE_FORMAT_LC2=%A, %d %B %Y %H:%M DATE_FORMAT_LC2=%B %d, %Y DATE_FORMAT_LC3=%d %B %Y DATE_FORMAT_LC4=%d.%m.%y DATE_FORMAT_JS1=y-m-dcopy code
Theoretically, all of the core components of the Joomla framework use these definitions for their date formats, and the formats correspond to the PHP date function. Change these settings to whatever you’d like, and enjoy the convenience of seeing your change applied globally.