Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#49 2010-09-10 12:10:14

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

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.

Txp Builders – finely-crafted code, design and Txp

Offline

#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

#51 2010-09-10 16:16:19

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

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_time so 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/superman and /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.

Txp Builders – finely-crafted code, design and Txp

Offline

#52 2010-09-13 13:53:08

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

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 =&gt; 'page NOT LIKE \'/\'',
  1 =&gt; 'page NOT LIKE \'\'',
  2 =&gt; 'page NOT LIKE \'%q=%\'',
  3 =&gt; 'page NOT LIKE \'%c=%\'',
  4 =&gt; 'page NOT LIKE \'%pg=%\'',
  5 =&gt; 'page NOT LIKE \'%category=%\'',
  6 =&gt; 'page NOT LIKE \'/category/%\'',
  7 =&gt; 'page NOT LIKE \'%author=%\'',
  8 =&gt; 'page NOT LIKE \'/author/%\'',
  9 =&gt; '(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__

Hablablow + Webdesignofficina

Offline

#53 2010-09-13 14:35:18

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

Re: smd_lately: recently viewed site articles

@hablablow, take a look at this post.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#54 2010-09-13 14:56:18

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

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__

Hablablow + Webdesignofficina

Offline

#55 2010-09-14 15:05:57

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

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__

Hablablow + Webdesignofficina

Offline

#56 2010-09-15 14:33:13

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

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__

Hablablow + Webdesignofficina

Offline

#57 2010-09-21 02:10:32

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

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);
     }

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#58 2010-09-21 02:16:16

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

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.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#59 2010-09-21 08:03:13

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

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__

Hablablow + Webdesignofficina

Offline

#60 2010-09-21 09:22:39

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

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.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB