Difference between revisions of "Latest News module with date"
From Joomla! Documentation
m |
JoomlaRalf (talk | contribs) |
||
(One intermediate revision by one other user not shown) | |||
Line 14: | Line 14: | ||
$lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid)); | $lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid)); | ||
$lists[$i]->text = htmlspecialchars( $row->title ); | $lists[$i]->text = htmlspecialchars( $row->title ); | ||
− | $lists[$i]->creationdate = JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC4'); | + | $lists[$i]->creationdate = JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC4')); |
$i++; | $i++; | ||
} | } | ||
Line 23: | Line 23: | ||
<source lang="php"> | <source lang="php"> | ||
<a href="<?php echo $item->link; ?>" class="latestnews<?php echo $params->get('moduleclass_sfx'); ?>"> | <a href="<?php echo $item->link; ?>" class="latestnews<?php echo $params->get('moduleclass_sfx'); ?>"> | ||
− | <?php echo $item->text | + | <?php echo $item->text; ?></a> |
</source> | </source> | ||
Line 30: | Line 30: | ||
<source lang="php"> | <source lang="php"> | ||
<a href="<?php echo $item->link; ?>" class="latestnews<?php echo $params->get('moduleclass_sfx'); ?>"> | <a href="<?php echo $item->link; ?>" class="latestnews<?php echo $params->get('moduleclass_sfx'); ?>"> | ||
− | <?php echo $item->text; ?></a> | + | <?php echo $item->text .'<br />'.$item->creationdate; ?></a> |
+ | </source> | ||
+ | |||
+ | If you only want on line, like this<br/> | ||
+ | ''07.06.10 My new news''<br/> | ||
+ | you need this code: | ||
+ | |||
+ | <source lang="php"> | ||
+ | <?php echo $item->creationdate .' ' ?> | ||
+ | <a href="<?php echo $item->link; ?>" class="latestnews<?php echo $params->get('moduleclass_sfx'); ?>"> | ||
+ | <?php echo $item->text; ?></a> | ||
</source> | </source> | ||
+ | |||
[[Category:Tips and tricks 1.5]] | [[Category:Tips and tricks 1.5]] | ||
[[Category:Tips and tricks]] | [[Category:Tips and tricks]] |
Revision as of 08:17, 15 June 2010
The "J1.5" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
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; ?></a>
to
<a href="<?php echo $item->link; ?>" class="latestnews<?php echo $params->get('moduleclass_sfx'); ?>">
<?php echo $item->text .'<br />'.$item->creationdate; ?></a>
If you only want on line, like this
07.06.10 My new news
you need this code:
<?php echo $item->creationdate .' ' ?>
<a href="<?php echo $item->link; ?>" class="latestnews<?php echo $params->get('moduleclass_sfx'); ?>">
<?php echo $item->text; ?></a>