web design, England, Britain, UK, belgium
 
Ulti Clocks content

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

GJC Web Design Joomla & VirtueMart how to, tips, tricks, coding examples, html, php, tutorial, 101, useful hints, help

A collection of help articles and coding examples for Joomla & Virtuemart

Belgium, VirtueMart & Joomla Web Design England UK Britain & Germany

Joomla, VirtueMart, how to, tips, tricks, coding examples, html, php, tutorial, 101, useful hints, help sand 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

Home Joomla - VirtueMart Joomla & VM How To's 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


Add this page to your favorite Social Bookmarking websites
Digg! Reddit! Del.icio.us! Mixx! Free and Open Source Software News Google! Live! Facebook! Slashdot! Technorati! StumbleUpon! Spurl! Newsvine! Furl! Fark! Yahoo! Netvouz! Mister-Wong! RawSugar! Ma.gnolia! Squidoo! DZone! Swik!
Last Updated on Wednesday, 22 April 2009 18:53 Read : 3644 times
 
Comments (2)
@Kevin
2 Saturday, 16 May 2009 06:20
GJC (admin)
Thanks, please social bookmark the article to "share" the knowledge....
Cool!
1 Saturday, 16 May 2009 05:14
Kevin
This is great! I just need it. Thanks!

Add your comment

BoldItalicUnderlineStrikethroughSubscriptSuperscriptEmailImageHyperlinkOrdered listUnordered listQuoteCodeHyperlink to the Article by its id
Very HappySmileWinkSadSurprisedShockedConfusedCoolLaughingMadRazzEmbarrassedCrying or Very SadEvil or Very MadTwisted EvilRolling EyesExclamationQuestionIdeaArrowNeutralMr. GreenGeekUber Geek
Your name:
Subject:
Comment:

Latest Articles

Paypal Donation

If you use this module on your site please donate a small amount.
Any donation amount appreciated.

VM Live Product Search

Recommended Reading

For those interested in extending there knowledge of Joomla! & VirtueMart Packt Publishing has an excellent range of help & how to books.
Listed below are some I can recommend.
Simply click on the images to be taken directly to their web shop.

Learning Joomla! 1.5 Extension Development Learning Joomla! 1.5 Extension Development
by Joseph L. LeBlanc.
Read the review
Joomla! E-Commerce with VirtueMart Joomla! E-Commerce with VirtueMart
by Suhreed Sarkar.
Read the review
Joomla! Web Security Joomla! Web Security
by Tom Canavan.

Mastering Joomla! 1.5 Extension and Framework Development Mastering Joomla! 1.5 Extension and Framework Development
by James Kennard.

Joomla! Template Design: Create your own professional-quality templates with this fast, friendly guide Joomla! Template Design: Create your own professional-quality templates with this fast, friendly guide
by Tessa Blakeley Silver.

GJC Web Design Joomla & VirtueMart how to, tips, tricks, coding examples, html, php, tutorial, 101, useful hints, help

A collection of help articles and coding examples for Joomla & Virtuemart

Belgium, VirtueMart & Joomla Web Design England UK Britain & Germany

Joomla, VirtueMart, how to, tips, tricks, coding examples, html, php, tutorial, 101, useful hints, help



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



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