Sep
9
Joomla! - Make Latest News Module Display Date
September 9, 2008 |
I have been using one of the default Joomla! module Lastest News for quite some time, it works really great for me. The only imperfection is that it doesn’t display date created by default. So I rolled my my sleeves and do it on my own. You need to edit two files to make it display date: /modules/mod_latesnews/helper.php and /modules/mod_latesnews/tmpl/default.php
In the helper.php, add the following chunk of code to the foreach loop located at the bottom of the page:
$lists[$i]->creationdate = JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC4');
so now the bottom looks like:
foreach ( $rows as $row )
{
$lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
$lists[$i]->text = htmlspecialchars( $row->title );
$lists[$i]->creationdate = JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC4');
$i++;
}
Now when the dates are collected with the mysql query, you need to add them to the default.php. Change this code in default.php:
<a href="<?php echo $item->link; ?>" class="latestnews<?php echo $params->get('moduleclass_sfx'); ?>">
<?php echo $item->text .'<br />'.$item->creationdate; ?></a>
to:
<a href="<?php echo $item->link; ?>" class="latestnews<?php echo $params->get('moduleclass_sfx'); ?>">
<?php echo $item->text; ?></a>
Similar Posts
- Joomla add Custom User Groups
- Joomla Loads Position Module within Content
- Proper Way to Use Joomla getNumRows
- Way to use Joomla loadAssoc
- Joomla - Link Excerpt Article Title to Full Article
- Remove Mootools From Joomla Header
- Joomla - Use loadObjectList and foreach to get list
- Install and Run Joomla on Ubuntu
- Joomla PDF Display Problem in IE7 Fix
- Joomla Manually Setup Enable SEF URL
- Make Joomla localhost Email Work
- Joomla Retrieve Admin Password


































