Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2009-09-13 18:32:45

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: smd_lately: recently viewed site articles

I like within="1 month" :)

If you want simplicity, you shouldn’t be using an smd_* plugin :oD

I ment simplicity for you as author :)


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#26 2010-02-19 20:54:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,515
Website GitHub

Re: smd_lately: recently viewed site articles

New version released. Although it doesn’t have the_ghost’s suggestion built in yet (I forgot, oops) I’ve put a couple of new attributes in to help make the output better:

  • include and exclude allow you to filter which pages are shown based on full-match or a regex partial match with either the ip address, the host, the referer or the page URL. Useful for omitting your own clicks
  • status allow you to only show articles that have certain status values
  • time allows you to only show articles in the future or the past (or any, as it was before). It’s bizarre to think that a log entry could be in the future but consider the case where you have written a post for future publication. You click on it to preview it and it pops up in your logs. You might not want people knowing it’s there until it’s published, so limiting the time display to only past articles means you can preview future articles without anybody finding out

Please note if upgrading to v0.2 that the default behaviour has changed: the list is now limited to live articles published in the past. Give it a spin and let me know how it performs. I’ll try and remember to include the_ghost’s suggestion in the next version.


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

#27 2010-04-28 04:26:40

sereal
Member
From: Indonesia
Registered: 2010-02-18
Posts: 55

Re: smd_lately: recently viewed site articles

hi Mr.Stef

I put your code like this one below but only works for a week then stop to work, its not displaying afterwards

<txp:smd_lately by=”“ wraptag=“ul” break=“li” class=“hotList” limit=“4” time=“past” status=“4”> <txp:permlink><txp:title /></txp:permlink> [{smd_lately_count}]<br /> <txp:posted /> oleh <txp:custom_field name=“Author” />
</txp:smd_lately>

any idea why this happen sir ? is there something wrong on my tags ?

kind regards


$(mydocument).notyetready(function() {});
dowebsitesneedtolookexactlythesameineverybrowser ?

Offline

#28 2010-04-28 08:06:47

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,515
Website GitHub

Re: smd_lately: recently viewed site articles

sereal wrote:

only works for a week then stop to work, its not displaying afterwards

Nothing wrong with your tag. What is the setting of Logs expire after how many days? in your Advanced Prefs? If it’s set to 7 days, that’s probably the answer :-)


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

#29 2010-04-28 09:35:29

sereal
Member
From: Indonesia
Registered: 2010-02-18
Posts: 55

Re: smd_lately: recently viewed site articles

yes it was set to 7 days , then
I try to change it to 1 day and still won’t display :(
should I clear the logs first ? or may be there is a good trick for this Sir ? I’d love to know

kind regards

Last edited by sereal (2010-04-28 09:36:42)


$(mydocument).notyetready(function() {});
dowebsitesneedtolookexactlythesameineverybrowser ?

Offline

#30 2010-04-28 09:47:59

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,515
Website GitHub

Re: smd_lately: recently viewed site articles

sereal wrote:

I try to change it to 1 day and still won’t display :(

It won’t. You need to set it to a much longer time frame (say, 30 days or more?) Then, when your visitors start clicking on stuff the logs will be populated and smd_lately will start to do its job. The plugin only reads what is in the logs, so if they expire (i.e. old hits get deleted) after 7 days you’ll have no information for smd_lately to look at.

Remember, the plugin shows what your visitors have been clicking lately, not forever. You can increase the definition of ‘lately’ by setting your logs to expire less frequently :-)


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

#31 2010-04-28 09:54:30

sereal
Member
From: Indonesia
Registered: 2010-02-18
Posts: 55

Re: smd_lately: recently viewed site articles

hmm I see

let me try that and I’ll report it in the next 2 months :D

thanks mr.Stef


$(mydocument).notyetready(function() {});
dowebsitesneedtolookexactlythesameineverybrowser ?

Offline

#32 2010-05-10 15:35:29

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,515
Website GitHub

Re: smd_lately: recently viewed site articles

Slight pimpage in the latest version 0.21:

  • added from, to and within so you can limit your log files searching to date & time ranges (thanks the_ghost)
  • added wildcard like matches to include and exclude which (I believe) are slightly faster than REGEXPs. Only use regex if you really need it for regular expression matches. In most cases you can get away with something like exclude="page:like:http, page:like:../" to filter out a whole slew of inane script-kiddie attacks on your sites
  • replaced a load of internal REGEXP matches with LIKE for performance reasons. Shaves a few milliseconds off the plugin, and it all counts

Give that a whirl and see how she handles.


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

#33 2010-05-27 22:06:22

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

Re: smd_lately: recently viewed site articles

Hi Bloke,
I’m having some issues while playing with this plugin. Not sure if it’s my fault, or some plugin quirkiness, or even both.

First question first:

1) Is it compatible with TXP 4.0.7? I see you made it compatible with TXP 4.0.8, but as I’m currently doing some updates on an already hard-modded TXP 4.0.7, I’m restraining of trying to upgrade to 4.0.8 or even 4.2.0.

Now, this are the quirky quirks I’m having

  • minor one: when using wraptag="ul" but not specifying class attribute, I get <ul class="__FUNCTION__"> in the output.
  • not-so-minor-one: even if it seems to be iterating over something, I’m just getting empty output.

The code:

<txp:smd_lately by="SMD_ALL" sort="popularity asc" limit="10" wraptag="ul" break="li">
  <txp:title />
</txp:smd_lately>

That will output 10 empty <li>s.

The other weird thing is that the first time I dropped <txp:smd_lately /> tag on the template (without using as container, but in its self-closing mode, and without specifying any form), I’m pretty sure it generated some output pointing to, at least, one article. This output was wrong too, as I was getting 9 empty <li>s.

So, not sure what could be going on here, really. As always, I’ll appreciate your guidance.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#34 2010-05-27 22:52:52

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,515
Website GitHub

Re: smd_lately: recently viewed site articles

maniqui wrote:

Is it compatible with TXP 4.0.7?

Don’t see why not. Can’t think of anything introduced in 4.0.8+ that the plugin needs.

<ul class="__FUNCTION__">

D’oh that’s me being a tool. I put the default item in quotes when it shouldn’t be. Sorry about that. Find line 26 and remove the single quotes from around __FUNCTION__. I’ll fix that tomorrow.

I’m just getting empty output.

A few things, in no particular order:

  • Are you logging all hits, and do your visitor logs show entries?
  • What happens if you sort by descending popularity instead of showing the 10 least popular?
  • Are you using any complicated gbp_permanent_links magic anywhere that might be interfering with the logging?
  • What do you see with debug="2" (or 3) switched on? With level 3 on you should see the records for all 10 articles. Does that give you any clues why it’s misbehaving?

Past that I can’t think of anything off the top of my head. The above might trigger some further thoughts if you post your findings. I hope!


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

#35 2010-05-28 02:15:27

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

Re: smd_lately: recently viewed site articles

Hi Bloke, thanks for your prompt reply.

<ul class="__FUNCTION__">
D’oh that’s me being a tool. I put the default item in quotes when it shouldn’t be. Sorry about that. Find line 26 and remove the single quotes from around __FUNCTION__. I’ll fix that tomorrow.

Done, and it works. Thanks.

  • Are you logging all hits, and do your visitor logs show entries?

Yes, I forgot to mention that, but yes, it is login correctly.

  • What happens if you sort by descending popularity instead of showing the 10 least popular?

No change, but don’t worry… because…

  • Are you using any complicated gbp_permanent_links magic anywhere that might be interfering with the logging?

We have a winner!

I also was suspecting of gbp_permanent_links, but, at a first glance, gbp_p_l wasn’t interfering with the logging. Hits were being logged successfully, so there was nothing suspicious there. I also sneak-peeked at smd_lately plugin code and see that “url_title” was a key element on the fetching of logs, so definitely there was a clue on that path…

So, after reading your question, I temporarely disabled gbp_p_l but nothing changed: smd_lately iterated over something, as in the output I could see that it was a DOM element for each iteration.
I know it was iterating over logs, because after re-initiating my tests, I cleaned/emptied all the logs, and hit a few pages, just to log a few (three or four) new entries.
And the quantity of DOM elements coincided with the quantity of articles logged on the visitors log.

So… as gbp_p_l still didn’t seem to have any relation with the issue, I continued with your next question…

  • What do you see with debug="2" (or 3) switched on? With level 3 on you should see the records for all 10 articles. Does that give you any clues why it’s misbehaving?

So, then, there is a debug attribute? No mention about it on plugin’s official page ;)
I should have discovered it by looking at plugin’s code… but well, I can’t see the whole Matrix yet.

So, I turned debugging, first on 2, then on 3, and looking at the output, I noticed that, as you said, it was outputting some records. But the weird thing was that it every record in the output was the same, and to be more precise, the record (the article) wasn’t any of the logged articles.

I inspected more carefully the output and I saw this line:

select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where url_title='' AND Posted < CURDATE()

So, url=title='' was querying for articles without an url_title. I thought I had a winner there, and found that, among the +700 articles there were two without title nor url_title.
Fixed that, but no luck either. Of course, the plugin was still querying for where url_title='', but at least, this time, there were no records.

And that’s when I looked again at the plugin code, and found this comment:

// Note the regexp is anchored to the end with a $

And that’s when I heard the “click” that anyone loves to hear when tracking down this kind of issues.
I remembered (and confirmed by looking at plugin’s debug output) that gbp_permanent_links has an option, enabled by default, to append a trailing slash to permanent links.
So, logged permanent links, instead of being section/article-title, they were section/article-title/. And that’s the reason why smd_lately couldn’t process them properly and was trying to query where url_title=''.

I temporarily changed the option on gbp_p_l, logged a few new hits, and tada!! smd_lately began to output article’s content (title, etc) on each iteration. :D

Past that I can’t think of anything off the top of my head. The above might trigger some further thoughts if you post your findings. I hope!

Yes, it did trigger some further thoughts, thank you very much!

Now, well, I’ve been looking thru smd_lately code, but I couldn’t find the anchored-to-$ regexp that captures the url_title.
Do you think it could be possible to modify smd_lately to ignore any trailing slash on url_title, without affecting other trailing slash, like the ones at /section-name/?
In other words, to make it compatible with both types of url_titles: with and without trailing slash, so it will make it compatible with plugins like gbp_p_l.
In fact, vainilla TXP article URLs seems to work both with or without the trailing slash, so I would believe that TXP logs them as they are hit (with or without the trailing slash).


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#36 2010-05-28 03:48:18

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

Re: smd_lately: recently viewed site articles

OK, I put my programmer-wannabe hat on, and found a way to let smd_lately work with both type of URLs (with and w/o trailing slash):

Replace this line (269).

$urlparts = explode('/', $row['page']);

with this one:

$urlparts = explode('/', rtrim($row['page'],"/"));

And that’s all!

Of course, I hope Bloke blesses this change (or improves over it).


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB