Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-07-23 13:46:03

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,456
Website GitHub

smd_lately: recently viewed site articles

Use this plugin to show one of two types of output:

  1. A list of popular articles, optionally limited to a section or three (Am I hot or not, anyone?)
  2. A list of recently viewed articles, again limited to the given sections if you wish (What have I or everyone else looked at lately?)

For each type you can choose to show articles only viewed by the current visitor, or from all visitors to your site so you can show what’s popular or simply show a user what products they’ve recently looked at in your online shop (like Amazon do). Each entire article is available for use inside the container so any standard tags or article plugins are fair game in your list. It is strongly recommended you employ the cache_time attribute to avoid hammering your database.

It uses the visitor logs for the plugin’s trickery so it won’t work if you aren’t logging all hits. This also means that any visitors using an anonymising proxy will get spurious (or no) results. Their loss, right?

Download the plugin and have fun.

Revision history
————————

All available versions and changes are listed here. Each entry indexes the relevant post(s) in the thread to learn about the features.

  • 19 Mar 20 | 0.4.0 | For Txp 4.8.0+ ; Fix find_temp_dir() error (thanks, Robert Newell) ; Fix missing column ip warnings ; Remove by attribute, since Txp no longer tracks IP address. ; Register tag ; Add Textpack.
  • 10 Sep 10 | 0.3.0 | Added cache_time (thanks maniqui/pieman) ; now only uses two queries regardless of number of results ; improved messy URL support ; fixed time display problems using NOW() and added active_class (both thanks jelle)
  • 28 May 10 | 0.2.2 | Fixed default class attribute and removed trailing slash from pages (both thanks maniqui)
  • 10 May 10 | 0.2.1 | Added from, to within (thanks the_ghost) ; added like matching ; used LIKE instead of REGEXP internally for performance reasons
  • 19 Feb 10 | 0.2.0 | Added include, exclude, time, status, delim and param_delim ; changed default behaviour to time="past" and status="4"
  • 11 Sep 09 | 0.1.3 | Added replacement variables
  • 10 Aug 09 | 0.1.2 | never assume the article title that has been stripped out of the log file is valid
  • 24 Jul 09 | 0.1.1 | Made backwards compatible with TXP 4.0.8
  • 23 Jul 09 | 0.1.0 | Initial release

Last edited by Bloke (2020-04-22 13:23:25)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#2 2009-07-23 15:21:02

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: smd_lately: recently viewed site articles

Nice, steffer…

You know what would also fit nicely under the corporate mission-statement of this plugin? You don’t? Well, let me tell you in as many words as possible.

A conditional with an time since posted threshold. It would be magnificent to restrict/style articles with/by their ageism, that is appellations like “new”, “fresh” and/or “wet behind his/her ears”.

What do you think?

Offline

#3 2009-07-23 16:32:37

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,456
Website GitHub

Re: smd_lately: recently viewed site articles

mrdale wrote:

A conditional with an time since posted threshold.

If you don’t mind ‘new’ and ‘fresh’ et al being determined by your site visitors instead of by you, then it’s a fine idea. Or do you mean another tag you can use inside the article that determines how long since <txp:posted />?

Last edited by Bloke (2009-07-23 16:33:00)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2009-07-23 18:32:39

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: smd_lately: recently viewed site articles

I did actually mean another tag (article context) that would allow a threshold mechanism to determine whether it’s new based on posting date.

but I found it

…as you were…

Offline

#5 2009-07-23 19:04:32

paperboy
Member
From: Gothenburg, SE
Registered: 2006-01-24
Posts: 30
Website

Re: smd_lately: recently viewed site articles

Thanks Stef! Tested it quickly and got it working right away! (which is more than I can say about previous plugins like this I’ve tried. :D)

Offline

#6 2009-07-23 19:27:07

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,456
Website GitHub

Re: smd_lately: recently viewed site articles

paperboy wrote:

Tested it quickly and got it working right away! (which is more than I can say about previous plugins like this I’ve tried. :D)

Thanks. Glad it worked for you. I kludged it together in the early hours of this morning so it’s a bit of a miracle it worked at all. I’m not sure it’s found its niche yet, but it’s still early days. If you can think of anything that’ll improve it, please let me know and I’ll see what I can do.

As a general note, it is rather restrictive basing an entire plugin off the visitor logs because they’re not in the friendliest format. I think I caught all the corner cases for non-articles but if anyone spots a rogue article list link appearing, please let me know under what circumstances it appears and I’ll try to stamp on it.

Also, if you visit the Visitor Logs from the admin interface, I believe they get purged (unconfirmed but I think that’s how it works?) So one caveat I forgot to mention in the docs was to stay out of that tab! Plus, the quality of the results in your list will probably depend on your log file rotation. If you find you’re not getting good quantites of links (especially when using it to gauge popularity) it might make sense to whack the number of days up a bit in the Advanced Prefs.

Last edited by Bloke (2009-07-23 19:28:08)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#7 2009-07-23 20:01:30

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: smd_lately: recently viewed site articles

Really interesting… and finally a good reason to keep visitor logs turned on.
Haven’t tested it yet, but… does the plugin offer usual textpatternish way (using form or container tags) of customizing output? (being a smd_ plugin, I don’t doubt it has more attributes than… than… well… than any thing that has many attributes!).

In any case, this plugin could be useful to create some real breadcrumbs, breadcrumbs that shows were the user has been instead of more common breadcrumbs that show in which “branch” of the sitemap the user is standing on.
In other words, a browser back button / history integrated directly on the site…

I think it can help to increase site usability, although I would like to read somewhere (Jakob Nielsen maybe?) if this lists of “recently pages viewed by you” are useful (me thinks the answer is yes).

Last edited by maniqui (2009-07-23 21:07:09)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#8 2009-07-23 20:43:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,456
Website GitHub

Re: smd_lately: recently viewed site articles

maniqui wrote:

does the plugin offer usual textpatternish way (using form or container tags) of customizing output?

Absolutely. When it finds a log entry it looks up the article and allows you to use any article tags (or related plugins) in the container/form so you could get really freaky and show part of an image gallery from an article that someone viewed recently. For that reason it’s not the lightest plugin in the world in terms of queries — one per recent article + one or two (depending on your options) up front. But the flexibility of being able to show anything from the article outweighed the desire to cheat and make it a Diet version of the plugin it could be.

(being a smd_ plugin, I don’t doubt it has more attributes than… than… well… than any thing that has many attributes!)

Oddly, I was very restrained this time… ahem, so far :-)

In other words, a browser back button / history integrated directly on the site…

Holy disco fudge cake, I’d not considered that angle. You’re totally right though. Out of the box in the ‘per user’ mode, it is an exact trail of which articles you’ve clicked. Mighty cool thinking there, sir.

The original intention was to do the whole “Products you’ve looked at recently” thing that you see in amazon.com’s sidebar. I realised the ‘most popular’ idea was a quick win in the process, so added that into the mix. And that’s about the extent of my thought process. Glad you’re around to enhance my vision :-)

Last edited by Bloke (2009-07-23 20:45:03)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#9 2009-07-24 00:25:07

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: smd_lately: recently viewed site articles

Bloke wrote:

Also, if you visit the Visitor Logs from the admin interface, I believe they get purged (unconfirmed but I think that’s how it works?)

I visit the page all the time on multiple installs and have never had the data purged. There is a Logs expire after how many days? setting in preferences.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#10 2009-07-24 08:04:01

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,456
Website GitHub

Re: smd_lately: recently viewed site articles

MattD wrote:

I visit the page all the time on multiple installs and have never had the data purged.

OK, I sit corrected, thanks for the confirmation. For some reason I thought visiting the tab triggered some clean up operation. Must have dreamed it!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#11 2009-07-24 13:05:38

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,456
Website GitHub

Re: smd_lately: recently viewed site articles

Small update. Just realised I’d inadvertently made it a TXP 4.2.0-only plugin by using the remote_addr() function. v0.11 is now backwards compatible with TXP 4.0.8. Sorry for the hiccup.

Last edited by Bloke (2009-07-24 13:08:06)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#12 2009-08-10 03:24:56

mwr
Member
From: Canada
Registered: 2006-01-31
Posts: 167
Website

Re: smd_lately: recently viewed site articles

Sorry, but I can’t get it to work with sections. For example

<txp:smd_lately by=”“ sort=“popularity” />

works as advertised, but

<txp:smd_lately by=”“ section=“games” sort=“popularity” />

shows nothing.

I’m using TXP 4.0.8.


Mark

Offline

Board footer

Powered by FluxBB