Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2017-01-22 09:18:04

Gallex
Member
Registered: 2006-10-08
Posts: 1,148

plugin for display most viewed articles

as i understand this can’t be done without plugin? if so, please suggest any which is working correctly in txp 4.6.
features: display most viewed articles from certain section, category, current month, year.

Offline

#2 2017-01-22 13:07:19

Gallex
Member
Registered: 2006-10-08
Posts: 1,148

Re: plugin for display most viewed articles

choosed smd_lately

…and needed to add this to the beginning of a plugin:

Txp::get('\Textpattern\Tag\Registry')
   ->register('smd_lately');

Offline

#3 2017-01-23 18:00:48

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,203
Website

Re: plugin for display most viewed articles

uli wrote #268314:

There’s this handful of plugins that all write to the database, one way or another (alphabetical, not by popularity):

There is also ort_article_psort but I am afraid many of these are pretty dated.

Offline

#4 2017-01-23 22:24:58

etc
Developer
Registered: 2010-11-11
Posts: 3,354
Website

Re: plugin for display most viewed articles

Gallex wrote #303648:

as i understand this can’t be done without plugin? if so, please suggest any which is working correctly in txp 4.6.
features: display most viewed articles from certain section, category, current month, year.

If you don’t need to count unique visitors, that’s easy to do. Just chose a custom field (say, custom_10) that will store article hits. Then insert this into your individual article form:

<txp:php>safe_update('textpattern', 'custom_10=custom_10+1', 'ID='.parse('<txp:article_id />'));</txp:php>

and call

<txp:article_custom sort="custom_10+0 desc" />

to sort articles by the number of views.

Online

#5 2017-01-24 08:51:47

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: plugin for display most viewed articles

etc wrote #303664:

If you don’t need to count unique visitors, that’s easy to do. Just chose a custom field (say, custom_10) that will store article hits. Then insert this into your individual article form:

<txp:php>safe_update('textpattern', 'custom_10=custom_10+1', 'ID='.parse('<txp:article_id />'));</txp:php>...

and call

<txp:article_custom sort="custom_10+0 desc" />...

to sort articles by the number of views.

Nice simple tip …easily customizable to display last viewed articles (what smd_lately also do):

<txp:php>safe_update('textpattern', 'custom_10='.time(), 'ID='.parse('<txp:article_id />'));</txp:php>


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#6 2017-01-24 12:51:32

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,342
Website

Re: plugin for display most viewed articles

both of these tips would be excellent for txptips. would you guys please submit them there?


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | Respbublika! | NeMe @ github

Offline

#7 2017-01-25 07:55:03

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: plugin for display most viewed articles

colak wrote #303667:

both of these tips would be excellent for txptips. would you guys please submit them there?

I’m quite busy for now but I’ll try to write it in the next weeks if etc can’t do it before.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#8 2017-01-25 12:28:18

etc
Developer
Registered: 2010-11-11
Posts: 3,354
Website

Re: plugin for display most viewed articles

NicolasGraph wrote #303670:

I’m quite busy for now but I’ll try to write it in the next weeks if etc can’t do it before.

I have no time atm, sorry, please do. But I would enhance it a little more, to avoid

  • bots hits (User-Agent?)
  • fast reloads from the same IP (store the last IP in another cf?)

Or set a cookie?

Online

#9 2017-02-08 09:12:26

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 243

Re: plugin for display most viewed articles

It’s very nesessary thing for a CMS.
I’m sure Oleg can prepare something best ;-) as he mentioned:

— to avoid: bot hits, fast reloads ….

Offline

Board footer

Powered by FluxBB