Ulti Clocks content

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

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 Tips How to display the number of article hits & creation date in the Latest News Module - Joomla 1.5

Mer

22

Avr

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

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:
  The word for verification.
Lowercase letters only with no spaces.

The word for verification.<br/>Lowercase letters only with no spaces.
Word verification:

Titre:
Comment:
Comments (2)
@Kevin
2 Samedi, 16 Mai 2009 06:20
GJC (admin)
Thanks, please social bookmark the article to "share" the knowledge....
Cool!
1 Samedi, 16 Mai 2009 05:14
Kevin
This is great! I just need it. Thanks!



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