web design, England, Britain, UK, belgium
 

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

Display the number of page views (hits) for an article within the normal Joomla Article layout.

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

Sat

18

Apr

How to display the number of article hits in the Article 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 Article layout.

You can see how it looks on the article pages.


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



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



Display the number of page views (hits) for an article within the normal Joomla Article layout.


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

|

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.