Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#46 2010-09-09 15:16:17
- jelle
- Member
- Registered: 2006-06-07
- Posts: 165
Re: smd_lately: recently viewed site articles
Check, check, check
Using just <txp:smd_lately/>
Logging is set to All Results.
Got some entries.
Shall I pm you a login….I’m probably doing something stupid. :)
Offline
Re: smd_lately: recently viewed site articles
jelle wrote:
Check, check, check
OK, cool. Just checking :-)
Using just <txp:smd_lately/>
Right, so that’s only showing results per user. If you’re testing it yourself it should only show articles you’ve visited. It might be worth tring to add by="" just to see if it’s working at all. Also adding debug="2" will show you if there’s any output. If that doesn’t help give some insight into what’s going on, by all means send me a login and I’ll see if I can find out what’s going on.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Online
#48 2010-09-10 11:45:06
- jelle
- Member
- Registered: 2006-06-07
- Posts: 165
Re: smd_lately: recently viewed site articles
Hi bloke.
Thanks for pointing out that debug attribute. Gave me some insight to the problem.
This morning, without any changed to my test setup, smd_lately started spitting out articles where yesterday it would just sit there in silence. I’m guessing I have it’s a date/time issue somewhere.
To reproduce I wrote some articles. Clicked on them on the frontend…without result by smd_lately. After pushing back the publish date for the articles with 1 day smd_lately shows them.
My settings for timezone and daylight saving time are all correct. Setting the ‘to’ attribute to a future day didn’t work.
Here’s my debug code
select name from txp_section where 1=1
++ smd_lately RULES ++
array (
0 => 'page NOT LIKE \'/\'',
1 => 'page NOT LIKE \'%q=%\'',
2 => 'page NOT LIKE \'%c=%\'',
3 => 'page NOT LIKE \'%pg=%\'',
4 => 'page NOT LIKE \'%category=%\'',
5 => 'page NOT LIKE \'/category/%\'',
6 => 'page NOT LIKE \'%author=%\'',
7 => 'page NOT LIKE \'/author/%\'',
8 => 'page NOT REGEXP \'^/(aaa|default)/?$\'',
)
SELECT count(page) as popularity, page, MAX(time) as time FROM txp_log WHERE 1=1 AND ip='127.0.0.1' AND page NOT LIKE '/' AND page NOT LIKE '%q=%' AND page NOT LIKE '%c=%' AND page NOT LIKE '%pg=%' AND page NOT LIKE '%category=%' AND page NOT LIKE '/category/%' AND page NOT LIKE '%author=%' AND page NOT LIKE '/author/%' AND page NOT REGEXP '^/(aaa|default)/?$' AND status = 200 GROUP BY page ORDER BY time desc
array (
0 =>
array (
'popularity' => '1',
'page' => '/textpattern-4.2.0/index.php?id=3',
'time' => '2010-09-10 13:06:05',
),
1 =>
array (
'popularity' => '4',
'page' => '/textpattern-4.2.0/aaa/test-3',
'time' => '2010-09-10 12:51:49',
),
2 =>
array (
'popularity' => '2',
'page' => '/textpattern-4.2.0/aaa/test-1',
'time' => '2010-09-10 12:50:04',
),
3 =>
array (
'popularity' => '1',
'page' => '/textpattern-4.2.0/aaa/test-5',
'time' => '2010-09-10 12:49:51',
),
4 =>
array (
'popularity' => '1',
'page' => '/textpattern-4.2.0/aaa/test-2',
'time' => '2010-09-10 12:49:48',
),
5 =>
array (
'popularity' => '1',
'page' => '/textpattern-4.2.0/',
'time' => '2010-09-10 12:49:34',
),
)
select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where url_title='index.php?id=3' AND Posted < CURDATE()
select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where url_title='test-3' AND Posted < CURDATE()
select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where url_title='test-1' AND Posted < CURDATE()
select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where url_title='test-5' AND Posted < CURDATE()
select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where url_title='test-2' AND Posted < CURDATE()
select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where url_title='textpattern-4.2.0' AND Posted < CURDATE()
In the above code all the articles are dated 10th of september except “222” which is dated 9th of september. Only 222 is output by smd_lately. Don’t know how to go on. Is it a bug or maybe a server config issue? Any help is greatly appreciated, really like the functionality of this plugin.
Edited for code display — Stef
Last edited by Bloke (2010-09-10 11:55:02)
Offline
Re: smd_lately: recently viewed site articles
jelle wrote:
I’m guessing I have it’s a date/time issue somewhere.
Yes, sounds like it. I think I may have screwed up. Can you try something for me please? Go into the plugin code and search for CURDATE(). Replace both occurrences with NOW(), save it and see if that improves things. I’ve got a new version waiting to go now, so if that fixes it I’ll issue it today. Thanks.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Online
#50 2010-09-10 12:37:33
- jelle
- Member
- Registered: 2006-06-07
- Posts: 165
Re: smd_lately: recently viewed site articles
Great, that did the trick. Thanks!
While I’m at it..here’s an feature request: active_class attribute for the current article when show_current == 1
Thanks again…great plugin.
Offline
Re: smd_lately: recently viewed site articles
Right then, v0.30 is highly recommended because it can significantly reduce the load on your server. Features:
- Added
cache_timeso you can control how fresh the results are and stop hammering your database every page view (thanks pieman) - Due to internal improvements, the plugin now only uses two queries regardless of number of results (your hoster will be pleased)
- Improved messy URL support
- Filtering of
?params in non-messy mode - Results aggregated if possible (for example if your log has
/article/supermanand/article/superman?something=1, both will be attributed to/article/superman - Fixed time display problems using
NOW()(thanks jelle) - Added
active_class(thanks jelle)
Since this may impact existing lists, I’ve bumped the version number by a major revision. If you spot any oddness please let me know but I strongly recommend you use cache_time. Even something as low as 30 seconds will drastically reduce server load on high traffic sites.
Hope this helps stop people getting yelled at by their hosting provider.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Online
Re: smd_lately: recently viewed site articles
Hi Stef,
Thank you for this plugin…
I’m having some problems, it outputs nothing, and so turned debugging on and have this message:
++ smd_lately RULES ++<pre>
array (
0 => 'page NOT LIKE \'/\'',
1 => 'page NOT LIKE \'\'',
2 => 'page NOT LIKE \'%q=%\'',
3 => 'page NOT LIKE \'%c=%\'',
4 => 'page NOT LIKE \'%pg=%\'',
5 => 'page NOT LIKE \'%category=%\'',
6 => 'page NOT LIKE \'/category/%\'',
7 => 'page NOT LIKE \'%author=%\'',
8 => 'page NOT LIKE \'/author/%\'',
9 => '(page LIKE \'%s=collections%\')',
)
SELECT count(page) as popularity, page, MAX(time) as time FROM txp_log WHERE 1=1 AND page NOT LIKE '/' AND page NOT LIKE '' AND page NOT LIKE '%q=%' AND page NOT LIKE '%c=%' AND page NOT LIKE '%pg=%' AND page NOT LIKE '%category=%' AND page NOT LIKE '/category/%' AND page NOT LIKE '%author=%' AND page NOT LIKE '/author/%' AND (page LIKE '%s=collections%') AND status = 200 GROUP BY page ORDER BY time desc
I’m using gbp_permanent_links to have a section/category/title url scheme and so are the logs recorded when I read them in the Visitor logs tab.
Desactivating gbp_permanent_links throws a longer list of errors, but outputs the list defined with the smd_lately tag…
The only urls that the plugin needs to look at are in this case section/category/title…
Any chance I can do something for this type of urls ?
Thanks in advance…
_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__
Offline
Re: smd_lately: recently viewed site articles
@hablablow, take a look at this post.
Offline
Re: smd_lately: recently viewed site articles
Julian,
omit_trailing_slash set to yes in permanent links preference tab might do the trick… I’ll let you know…
Gracias por el link !
_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__
Offline
Re: smd_lately: recently viewed site articles
Well it seems impossible in my case, but thanks to Andreas I have found a workaround using:
<txp:gbp_disable_permlinks> … </txp:gbp_disable_permlinks>
So I can still use smd_lately without turning gbp_permanent_links off.
Last edited by hablablow (2010-09-14 15:06:35)
_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__
Offline
Re: smd_lately: recently viewed site articles
Stef,
Mmm… Of course using:
<txp:gbp_disable_permlinks> … </txp:gbp_disable_permlinks>
is only a shorthand solution as I have to rebuild my urls (section/category/title)
So I thought using this:
<txp:site_url /><txp:section /><txp:category /><txp:title />
But using <txp:category /> outputs: nothing but a hole in my url…
With debugging set to 3, the processed arrays contain the correct url since it’s the one recorded in the logs…
So I wish I could extract the value of ‘page’ => ‘section/category/title’
I can do plenty of things inside Txp, but I wish I could do that thing, yes !… But I can’t… Unless…
Cheese.
Last edited by hablablow (2010-09-15 14:34:00)
_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__
Offline
Re: smd_lately: recently viewed site articles
Hi Bloke,
As hablablow, I was also getting no output with v0.30. Then, if I switched back to v0.22, I’ve got output.
So, I’ve put my detective hat on, and I think I’ve found the issue.
After looking at debug output1 for both versions (v0.30, and v0.22), I found that for v0.30, I wasn’t getting any output for ++ ORIGINAL LOG LIST ++.
So I began to mass-delete some chunks of code, trying to find what was causing the issue.
The answer was on line 314:
if ($permlink_mode == 'messy')
For a moment, I thought “WTF, I’m not using ‘messy’ mode, so why this branch of the condition evaluating to true?”.
Then, I recall that gbp_permanent_links sets the $permlink_mode variable back to “messy”, to do its magic.
So, as a quick fix, I’ve changed every:
if ($permlink_mode == 'messy')
to:
if (!function_exists('gbp_disable_permlinks') && $permlink_mode == 'messy')
Yeah, a bit dirty. But it works!
I didn’t know how to test for the existence of an installed plugin, so I tested for a function created by that plugin.
Bloke, do you think this could be addressed in a nicer way on next smd_lately version? Or the dirty approach is good enough for you?
1 I had to disable this line to see the any debug output for debug > 1. If not, I got a Fatal error message regarding memory usage.
if ($debug > 1) {
dmp($rs);
}
Offline
Re: smd_lately: recently viewed site articles
BTW, version 0.30 isn’t compatible with 4.0.7.
To make it work, I had to comment out line 49, because it uses get_pref, and it’s not present on 4.0.7, me thinks.
Of course, commenting that line out left me with a smd_lately without caching powers.
As I’m trapped into a modded 4.0.7, it will take some time until I can upgrade it to 4.2.0.
I can live without the caching mechanism, and use aks_cache in the meanwhile.
But, of course, if some extra keystrokes could make it 4.0.7 compatible, that would be super.
Offline
Re: smd_lately: recently viewed site articles
Stef,
I’ve got also a detective hat, probably not the same model as Julián… While looking at it and smoking the pipe I can only see my code fail and I’m still deseperatly stuck into the problem mentioned above… Extract the url recorded in my logs, is the only way I imagine to retrieve the category name of an article…
But another special case has shown up recently: in the most popular article list when set to output a list of 5 I only have a list of 4 popular articles…
Julián, while my hat is not as sharp as yours I have been noticing this messy url condition and I’ll try your solution. Thanks or pointing this !
“Elementary, my dear Watson.”
Cheers !
Sorry for the mis-spelling of your name at first post Julián !
Last edited by hablablow (2010-09-21 10:12:34)
_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__
Offline
Re: smd_lately: recently viewed site articles
maniqui
Oooh, I didn’t know that gbp_pl set the permlink mode to messy by default. That will definitely cause havoc with my lamebrain coding in v0.30. Hmmmm, I gotta think this through a bit better. Thanks for sleuthing and doing my job for me!
Regarding 4.0.7, you’re right it won’t work as-is. If you want to mod it you can swap the get_pref() call for either:
$lastmod = isset($prefs[$var_lastmod]) ? $prefs[$var_lastmod] : 0;
or
$lastmod = safe_field('val', 'txp_prefs', "name='$var_lastmod'");
The first one is probably safe enough and more robust.
hablablow
I wonder if I should allow you to override the default rules if you don’t want them. The /category filter might be causing problems by removing stuff you need. Not sure why <txp:category /> would output nothing though. In what context are you using it? Can you share your relevant form/page tags that might give me some clues please?
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Online