[Solved] Display most viewed article in CGBlog?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
pwg
Forum Members
Forum Members
Posts: 191
Joined: Tue Aug 01, 2006 1:48 am

[Solved] Display most viewed article in CGBlog?

Post by pwg »

Hi,

Searched and can't see an obvious answer on how to provide a "most viewed" style option for sorting and displaying CGBlog posts.

I was wondering if I could use HitCounter to get the most visited pages, and use this info to display the most visited CGBlog posts?

In my CGBlog Detail template I added:

Code: Select all

{HitCounter key1="CGBlog" key2=$entry->id}
and I tried in a content section without any success.

Code: Select all

{HitCounter action=getmostvisited ndays=30 key1=CGBlog assign='theidlist'}
{foreach from=theidlist item=oneid}
  {CGBlog action=popular articleid=$oneid}
{/foreach}


Any ideas on how to make this work? Another way?

Thanks for any help.

Cheers,

Paul
Last edited by pwg on Sun Mar 15, 2015 12:59 am, edited 1 time in total.
pwg
Forum Members
Forum Members
Posts: 191
Joined: Tue Aug 01, 2006 1:48 am

Re: Display most viewed article in CGBlog?

Post by pwg »

Can somebody let me know if I'm asking a stupid question, that I should know the answer too, or if there is an obvious way to do this that I've missed, or any suggestions on where to look?

Thanks for any help.

Cheers,

Paul
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: Display most viewed article in CGBlog?

Post by Jo Morg »

pwg wrote:Can somebody let me know if I'm asking a stupid question, that I should know the answer too, or if there is an obvious way to do this that I've missed, or any suggestions on where to look?
Well it's not a stupid question, but the code you started up with doesn't make sense...

Code: Select all

{foreach from=theidlist item=oneid}
  {CGBlog action=popular articleid=$oneid}
{/foreach}
Where does this come from? There isn't any hint on CGBlog Help page that this action exists at all.

However on HitCounter Help:
{HitCounter action=popular [key1=string [key2=string]] [limit=number] [popular_template=string]
Sooo.... without any foreach loop, whi don't you just try:

Code: Select all

{HitCounter action=popular key1='CGBlog'}
That might do the trick.... :)

Note: I didn't tested though, but I shouldn't be too far...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
pwg
Forum Members
Forum Members
Posts: 191
Joined: Tue Aug 01, 2006 1:48 am

[Solved]Re: Display most viewed article in CGBlog?

Post by pwg »

Hi Jo, many many thanks for your help.

Instant results.

I came up with my odd code from an old forum question answered by Calguy - obviously I mangled the code - and answer.
http://forum.cmsmadesimple.org/viewtopic.php?t=37822

However, thanks again - very simple solution.

Cheers,

Paul
Post Reply

Return to “Modules/Add-Ons”