Show Hits At Frontpage & Category Pages

Note: Until second version of Module Hits AnyWhere is ready, I ask you to use the following guide to show hits at Category as well as Front Pages. As Hits AnyWhere Module shows hits at individual pages only to make your sit show hits at main website page and other pages following guide will help you:

Show Hits at Category Pages with Each Item:

You want to show the hits for every article in category page too?

You need to add the following code in your category page:

<@?php echo “Total Hits: “.$this->item->hits; ?>
(Remove @ from the start of this code.)
You can change the “Total Hits: ” with anything you want…

Ideally your joomla template should have html override folder…
i.e. you need to open this blog_item.php file, and add the above
code where you want to display the hits.

your joomla template > html > com_content > category > blog_item.php

This will work perfectly for you I am sure as we do this daily :-)
If you do not know how to edit template or your current tempalte dont
have the html override folder, let us know, and one of our coder will do
implement this for you.

Show Hits at Frontpage (Main page) of Your Joomla Site:

Just add the above code in the frontpage item i.e.

<@?php echo “Total Hits: “.$this->item->hits; ?>

(Remove @ from the start of this code.)
into the following file:
joomla template > html > com_content > frontpage > default_item.php

(Add this in the above file at the position where you want to show the hits)

But to make this code work you need to add one more little code at joomla page i.e.

Open components/com_content/models/frontpage.php
Search for this line at about 128th line:

$query = ‘ SELECT a.id, a.title, a.title_alias, a.introtext, a.fulltext……… big line :-)

you need to add this code (a.hits,) at the end before the “‘”
i.e.
a.attribs, a.urls, a.metakey, a.metadesc, a.access,

becomes :
a.attribs, a.urls, a.metakey, a.metadesc, a.access, a.hits,

This will make the code in template (you add at above heading) to work fine.

Refresh your site and see the hit counts it would work fine now.

Regards,

Mohsin Rasool

PS. If you want any customization, or this does not work in your situation. You can submit a support ticket at our desk and let one of our expert coder do this for you. Good Luck

Comments

  1. amir says:

    hi
    thaks for tut

    how can i to replace frontpage.php file in the html folder template.

Speak Your Mind

*