How to display the number of article hits in the Blog layout - Joomla 1.5 - Joomla & VirtueMart Tips & How To's

Display the number of page views (hits) for each article within the Joomla Blog content layout.

Home Joomla VirtueMart Tips How to display the number of article hits in the Blog layout - Joomla 1.5

Tue

14

Apr

How to display the number of article hits in the Blog layout - Joomla 1.5
  • Joomla 1.5
  • com_content

This change will display the number of times each article has been read (hits) in the Joomla 1.5 Content Blog layout.

You can see how it looks on this page.


Open file joomla_root/components/com_content/views/category/tmpl/blog_item.php in any text editor and go to line 124.
The table cell were interested in looks like this -
 
<?php if ( intval($this->item->modified)\n != 0 && $this->item->params->get('show_modify_date')) : ?>
<tr>
  <td colspan="2"  class="modifydate">
    <?php echo JText::sprintf('LAST_UPDATED2', JHTML::_('date', $this->item->modified, JText::_('DATE_FORMAT_LC2'))); ?>
 
  </td>
</tr>
<?php endif; ?>
 
You need to add the conditional clause to display the number of hits for each item.
The <?php endif; ?> have been moved as well -
 
<?php if ( intval($this->item->modified) != 0 && $this->item->params->get('show_modify_date')) : ?>
<tr>
  <td colspan="2"  class="modifydate">
    <?php echo JText::sprintf('LAST_UPDATED2', JHTML::_('date', $this->item->modified, JText::_('DATE_FORMAT_LC2'))); ?>
        <?php endif; ?>
        <?php if ($this->params->get('show_hits')) : ?>
   <span style="float:right;">
                  Read : <?php echo $this->item->hits; ?> times
   </span>
  </td>
</tr>
 
Now the number of times the article has been accessed (hits) is displayed.
Last Updated on Thursday, 16 April 2009 21:55
 
VirtueMart
Your Cart is currently empty.

Latest Joomla & VirtueMart Tips

See all tips & examples



How to display the number of article hits in the Blog layout - Joomla 1.5|Joomla & VirtueMart Tips & How To's



Display the number of page views (hits) for each article within the Joomla Blog content layout.


php, item, date, hits, modified, joomla, pre, jtext, endif, number, class, echo, content, params, times, xml, html, updated, jhtml, format, looks, display, article, com, div, read, blog, span, sprintf, colspan, intval, modifydate, modify, float, right, accessed, displayed, style, moved, add


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.