How to display the number of article hits & creation date in the Latest News Module - Joomla 1.5 - Joomla & VirtueMart Tips & How To's

How to display the number of article hits & creation date in the Latest News Module - Joomla 1.5

Home Joomla VirtueMart Tips How to display the number of article hits & creation date in the Latest News Module - Joomla 1.5

Wed

22

Apr

How to display the number of article hits & creation date in the Latest News Module - Joomla 1.5
  • Joomla 1.5
  • Module mod_latestnews

The Latest News module (mod_latestnews) can be adapted to show the creation date of your latest articles.

With a couple of small changes you can show the number of page views as well.

Latest News module Open file joomla_root/modules/mod_latestnews/helper.php in any text editor and go to line 113.
Add these 2 lines after the $lists[$i]->text = htmlspecialchars( $row->title ); -
 
$lists[$i]->hits = htmlspecialchars( $row->hits );
$lists[$i]->created = htmlspecialchars( $row->created );
 
so it looks like
 
$lists[$i]->text = htmlspecialchars( $row->title );
$lists[$i]->hits = htmlspecialchars( $row->hits );
$lists[$i]->created = htmlspecialchars( $row->created );
$i++;
 
Then open file joomla_root/modules/mod_latestnews/tmpl/default.php and go to line 7.
Add the php echo statement -
 
<?php echo "<div style='height:20px;'><span class='latestnews".$params->get('moduleclass_sfx')."'style='float:left;'> ";
    echo JHTML::_('date', $item->created,"$date_time_sys", $offset); 
    echo "</span><span style='float:right;' class='sharedby".$params->get('moduleclass_sfx')."'>Views: ".$item->hits."
                      </span>
            </div>";?>
 
so it looks like - 
 
<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>
<ul class="latestnews<?php echo $params->get('moduleclass_sfx'); ?>">
<?php foreach ($list as $item) :  ?>
  <li 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 "<div style='height:20px;'><span class='latestnews".$params->get('moduleclass_sfx')."'style='float:left;'> ";
    echo JHTML::_('date', $item->created,"$date_time_sys", $offset); 
    echo "</span><span style='float:right;' class='sharedby".$params->get('moduleclass_sfx')."'>Views: ".$item->hits."
                      </span>
            </div>";?>
 
  </li>
<?php endforeach; ?>
</ul>
 
You now have this.... Latest News module views
Last Updated on Wednesday, 22 April 2009 18:53
 
VirtueMart
Your Cart is currently empty.

Latest Joomla & VirtueMart Tips

See all tips & examples



How to display the number of article hits & creation date in the Latest News Module - Joomla 1.5|Joomla & VirtueMart Tips & How To's



How to display the number of article hits & creation date in the Latest News Module - Joomla 1.5


php, echo, latestnews, style, latest, span, class, hits, sfx, item, params, moduleclass, htmlspecialchars, created, lists, module, joomla, div, row, float, views, date, news, pre, height, title, text, right, mod, left, jhtml, line, sys, time, sharedby, add, access, html, like, xml


guru

We use cookies to improve our website and your experience when using it. Cookies used for the essential operation of the site have already been set.
To find out more about the cookies we use and how to delete them, see our privacy policy.

I accept cookies from this site.