J1.5

Latest News module with date: Difference between revisions

From Joomla! Documentation

Erdsiger (talk | contribs)
New page: You need two files: /modules/mod_latesnews/helper.php and /modules/mod_latesnews/tmpl/default.php In the helper.php, add the <source lang="php"> $lists[$i]->creationdate = JHTML::_('date...
 
Erdsiger (talk | contribs)
(No difference)

Revision as of 18:54, 1 August 2008

You need two files: /modules/mod_latesnews/helper.php and /modules/mod_latesnews/tmpl/default.php

In the helper.php, add the

$lists[$i]->creationdate = JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC4');

line to the bottom, so:

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

<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>