Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: smd_lately: recently viewed site articles
uli wrote:
does ID overrule category, does a combination result in an intersection?
Uli, it results in an intersection, so your solution should work. Searching by ID
is fast, but smd_lately
will be called for every category, only to retrieve and sort the same list… not very purist, indeed, and can be long.
Another solution would be to retrieve this “lately” list only once, and then filter it with etc_query
, along these lines (not tested).
In your subnav
article form, wrap the content in, say, article
tag, and add category markup:
<article data-cat1='<txp:category1 />' data-cat2='<txp:category2 />'>
...title, body and other article stuff...
</article>
Now pass <txp:smd_lately />
as data
to etc_query
and extract from it the articles following the order set by <txp:category_list />
:
<txp:etc_query parse="before"
data='<txp:smd_lately sort="popularity" section="XYZ" form="subnav" />'
/>
<txp:category_list wraptag="" parent="ABC" section="XYZ" exclude="ABC">
<li<txp:if_variable name="cat" value='<txp:category />'> class="active"</txp:if_variable>>
<txp:category title="1" link="1" section="resources"/>
{article[@data-cat1='<txp:category />' or @data-cat2='<txp:category />']}
</li>
</txp:category_list>
</txp:etc_query>
Offline
Re: smd_lately: recently viewed site articles
Does anyone have any indication whether smd_lately would use more and more resources? I have used it for over a year but recently my site became more and more unresponsive. I disabled the plugin and everything seemed to speed up. Perhaps something else was causing my problem but I just wanted to ask if smd_lately was a potential problem in this respect. Thanks for any insights.
Offline
Re: smd_lately: recently viewed site articles
clivewalker wrote:
Does anyone have any indication whether smd_lately would use more and more resources?
Yes it will if you rarely visit your Admin->Visitor Logs panel. As you’d expect, every time anyone/anybot hits your site, the visitor log table increases in size. When you visit a page that contains an smd_lately tag, it has to trawl through the entire log file to calculate the stats. More records = more processing time.
Although there’s a setting in Advanced prefs that governs how many days’ worth of logs to keep, it is (somewhat counter-intuitively) only taken into consideration when you visit the Admin->Visitor Logs panel. Thus your visitor log file is only truncated to the number of days specified in the pref IF you visit that admin-side panel. You’ll usually notice a delay before the panel is fully displayed if you have a truckload of records in the log, as it frantically deletes the older ones.
To cut down on resource load you should therefore:
- Keep a reasonably low value for the Logs expire after how many days preference.
- Visit the Admin->Visitor Logs panel fairly regularly (which will vary from site-to-site depending on traffic volume and the value of your pref) to reduce the number of records to the pref value.
- Use smd_lately’s
cache_time
attribute to reduce the number of times the table is hit. If you set it tocache_time="86400"
, for example, only one visitor per day will notice a slower-than-usual access time to each page with your smd_lately tag on it: everyone else will get much faster responses from the cached results. Of course, you sacrifice immediacy and your results will be a little ‘out of date’, so you should balance thecache_time
and Logs expire after how many days pref to match your average site traffic and desired freshness of information.
Hope that helps.
Last edited by Bloke (2013-05-03 13:43:38)
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
Re: smd_lately: recently viewed site articles
Many thanks, that’s very useful
Offline
Re: smd_lately: recently viewed site articles
New version 0.31 released, with one minor addition: the ability to filter by method (GET or POST) when using the include
or exclude
attributes. Thanks, kees-b.
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
Re: smd_lately: recently viewed site articles
Bloke wrote #279729:
New version 0.31 released, with one minor addition: the ability to filter by method (GET or POST) when using the
include
orexclude
attributes. Thanks, kees-b.
thanks to you!!
Offline
Re: smd_lately: recently viewed site articles
A nice extra with this addition: by using exclude="method:GET"
I get a nice list of spam victim articles, off course mixed with normal articles high in comments.
Last edited by kees-b (2014-03-14 11:20:44)
Offline
Re: smd_lately: recently viewed site articles
I’ve got smd_lately installed and working perfectly… it’s a site with a plurality of mobile users. Their IPs change frequently, so the visitor logs become a less than ideal way of keeping track of a users visited pages.
Cookies seem the likely way to keep track of mobile users. Could smd_lately be done using cookies instead of IP addresses?
Offline
Re: smd_lately: recently viewed site articles
towndock wrote #290122:
Could smd_lately be done using cookies instead of IP addresses?
Hmmm, that’s a good point about IPs. In the era of Tor and the like, it’s not ideal. Sadly, smd_lately only reads what’s in the visitor logs table and crunches that. It doesn’t do any tracking of its own. That’s not to say it couldn’t, but it would need one or two prefs adding and the associated admin UI, then some cookie code to replicate the sort of thing found in the visitor logs.
The plugin might be able to be retrofitted to allow the by
attribute to read the cookie info, but the trouble is, to track historical information means the cookie data would grow and grow every visit. That’s probably untenable long term, I’m not sure what the size limits are and what, if anything, the performance would be like. Maybe a setting to limit the validity window (number of days, number of hits, etc) would work so it didn’t get too big.
Or some combination of using a cookie and a custom tracking table similar to the way analytics work.
tl;dr, I’m unsure if it’s doable in its current guise. Most options seem to indicate pretty much a new plugin needs to be written!
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
Re: smd_lately: recently viewed site articles
Bloke wrote #290124:
then some cookie code to replicate the sort of thing found in the visitor logs.
Found some code called Recently visited Page Links with jQuery and Cookies that could be a good basis.
While I could just use that, it needs some TXP plugin magic so one can display by section, etc.
Bloke, I’m open to shamelessly bribing you for the sake of God, country and the TXP world. How many beers do I need to email?
Offline
Re: smd_lately: recently viewed site articles
Hi,
I’m having the same problem as brunodario concerning the limit
and section
attributes. Tested on Mamp and online, the limit attribute doesn’t work correctly (limit="3"
display only 2 articles and limit:="10"
display 6 articles). And If I use the section attribute, nothing is displayed at all (of course there are some articles in the section).
I don’t understand what could be wong. I used the plugin with success for a previous project (with these attributes) but for now I can’t make it work. I’ve disable any other plugin but nothing better…
Maybe someone found how to solve this…?
My code (but the problem is elswhere I think):
<txp:smd_lately section='<txp:section />' show_current="0" limit="3" form="article_preview" sort="popularity" wraptag="ul" class="article-list" break="" by="" within="1 month" />
Last edited by NicolasGraph (2015-06-23 11:07:56)
Offline
Re: smd_lately: recently viewed site articles
NicolasGraph wrote #291862:
limit="3"
display only 2 articles andlimit:="10"
display 6 articles
Hmmm. Presumably you have more than limit
articles that match your criteria in the visitor logs?
The section
attribute will only work if your permlink structure has /section
in it somewhere, but you’ve probably got that set. Without having access to the site it’s going to be difficult to diagnose. I kind of forgot to get to the bottom of brunodario’s issue, oops.
If you can’t figure it out, any chance I could have a login to your site please so I can poke around?
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