Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#71 2011-02-19 00:43:03

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

Re: smd_lately: recently viewed site articles

Stef, smd_lately is writting the cache data in the tmp folder inside the Textpattern folder, unfortunately, not in the Temporary directory path specified in the preferences, in the case of a multisite environement…

While reading your code I came accross this function:

find_temp_dir()

I assume you are using this function so that if a user omits to specify the Temporary directory path in his preferences, the function is still able to find the temp directory and add the cache data there…

Could you craft it a different way that if a user has not specified the temp path, by following this scenario:
A – Follow first the path to the temp directory such as defined in Temporary directory path and write the cache data there
B – If the path is not defined then use the find_temp_dir() function

That would make smd_lately run in a multisite environement and store it’s cache data in separate tmp folders under each site…

Is this suggestion correct ?

As you mentioned earlier, that’s probably a better way to go than to store each smd_lately cache file in one single folder, currently the Textpattern folder…

Cheese…

Last edited by hablablow (2011-02-19 00:47:47)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#72 2011-02-22 22:28:33

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

Re: smd_lately: recently viewed site articles

Stef,

“If you start getting clashes, we could see if adding a plugin attribute to specify the unique file name might help…”

Well, not exactly clashes but on a mutlisite environement the temp log files, written only under the main Textpattern folder as I said earlier, replace each other for each site :(

For site A and another B, the tmp log file will update it’s data for A… As a result B will fail in trying to fetch the data by reading the content of popular data for site A… =:(

In fact a very cool feature would be to be able to specify a name for the temp file and so every site A and B would only read his A_smd_lately and B_smd_lately file….

That would be supa-freshhhhhh !

Last edited by hablablow (2011-02-22 22:31:06)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#73 2012-01-27 18:59:41

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 204
Website

Re: smd_lately: recently viewed site articles

Hi Stef! I want to show in my article form How many times an article has been accesed. I tried this: <txp:smd_lately by="">[{smd_lately_count}]</txp:smd_lately> and I see [31] [19] [18] [24] , but I want to show just How many times ONE article [the current] has been read.

Thanks in advance.

Offline

#74 2012-01-27 19:57:26

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,844
Website

Re: smd_lately: recently viewed site articles

robhert wrote:

Hi Stef! I want to show in my article form How many times an article has been accesed.

Ah yes, smd_lately is designed to show a list of articles. It takes a small tweak to get it to only display one. Here’s the way I’d approach it. You need show_current="1" because you need the article being viewed. Since, by definition, the most recent logged hit will be the article currently on display, we can limit the list to just 1 item:

<txp:smd_lately by="" show_current="1" limit="1">
   [{smd_lately_count}]
</txp:smd_lately>

Try that and see how you get on. If you have high traffic sites there’s a (slim) possibility that the first article in the log might not be the current article being viewed. If that’s the case you can always try this variation which stores the current article ID in a txp:variable and then iterates over the list of smd_lately articles, comparing each one to the currently displayed article. The default limit of 10 is highly likely to be enough to include the current article:

<txp:variable name="current_article"><txp:article_id /></txp:variable>
<txp:smd_lately by="" show_current="1">
   <txp:if_variable name="current_article" value='<txp:article_id />'>
      [{smd_lately_count}]
   </txp:if_variable>
</txp:smd_lately>

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

#75 2012-01-27 20:48:51

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 204
Website

Re: smd_lately: recently viewed site articles

hi Stef! Thanks for your answer. I don’t know but I can’t make it work.

I tried the first:

<txp:smd_lately by="" show_current="1" limit="1"> [{smd_lately_count}] </txp:smd_lately>

But I couldn’t see anything. I tried with with limit=“3” and it worked once. And in my popular articles when I put limite=“5” I just see 3 popular articles. And when I limit to 7, I see 5. It is strange.

<txp:smd_lately show_current="1" by="" time="any" sort="popularity" form="top_popular" limit="7" />

What am I doing wrong?

Thanks in advance. (I tried the second code, with no success)

Offline

#76 2012-01-29 16:40:20

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 204
Website

Re: smd_lately: recently viewed site articles

hi again! I can’t get it work.

But I’m getting worried by this: I see 2 Popular Articles, when I limited to 5. (If you see the last post, the difference was 2, now it is 3.

This is my code

<txp:smd_lately show_current="1" by="" break="" time="any" sort="popularity" form="top_popular" limit="5" />

top_popular form:
<div class="top_link"><txp:permlink><txp:title /></txp:permlink></div>

Log is limited to 7 days.

Any ideas?

(Sorry bad English)

Last edited by robhert (2012-01-29 16:42:58)

Offline

#77 2012-05-15 19:54:52

brunodario
Member
From: Belo Horizonte, Brasil
Registered: 2007-09-19
Posts: 75

Re: smd_lately: recently viewed site articles

I’m running this plugin on a windows test environment and the result it’s a lot of warnings just like

“Tag error: <txp:smd_lately by=”“ limit=“6” form=“generic-module”/> -> Warning: Invalid CRT parameters detected on line 382
Tag error: <txp:smd_lately by=”“ limit=“6” form=“generic-module”/> -> Warning: Invalid CRT parameters detected on line 388

Also, i’ve got the same problem as described by Robhert: In order to list 2 most popular articles i have to use limit=“6” and, also, sorting using the section parameter doesn’t work, but in the end i’m pretty sure thats all related to the Warnings, am i right?

Is there a workaround so i can test this plugin on my localhost and then when publishing on a linux host i’ve just reinstall it with the original code?

Offline

#78 2012-05-15 20:51:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,844
Website

Re: smd_lately: recently viewed site articles

brunodario wrote:

I’m running this plugin on a windows test environment and the result it’s a lot of warnings

Unfortunately, Windows is a little bit backwards when it comes to time format converters. Some of them plain don’t work and I didn’t take that into account when I wrote the plugin. The warnings are just warnings though, so shouldn’t affect the operation of the plugin as long as you don’t try and use the replacements on the given line numbers. For example, line 382 on my v0.30 plugin is the {smd_lately_date} replacement (though quite why that one is a problem I don’t know as it is supposed to work in Windows).

If you do want to silence the warnings, prefix any call to strftime() in the plugin’s code with an at-sign, like this:

"{smd_lately_date}" => @strftime("%F", $theTime)

In order to list 2 most popular articles i have to use limit=“6”

That is just bizarre. If I put this code in my default Form:

<txp:smd_lately show_current="1" by="" break="" time="any" sort="popularity" limit="2">
<div class="top_link"><txp:permlink><txp:title /></txp:permlink> [{smd_lately_count}]</div>
</txp:smd_lately>

then I see two links and two counts of the most popular articles. If I repeatedly refresh any other article until it exceeds the current most popular article, the new leader appears linked on the page instead. I can’t figure why it would work for me and not for both of you, unless Windows has something to do with it.

You’re using plugin v0.30, right? And logging All hits and have the logs set to expire at a suitably large value?

sorting using the section parameter doesn’t work

Can you post your code please so I can try it? If you limit by section the sort should still work, allowing you to choose between time or popularity. But perhaps I never tested it well enough. I’ll give it a grilling.

Last edited by Bloke (2012-05-15 20:53: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

#79 2012-05-15 21:19:56

brunodario
Member
From: Belo Horizonte, Brasil
Registered: 2007-09-19
Posts: 75

Re: smd_lately: recently viewed site articles

Steff

Thx for your quick reply.
Yes, i’m using Texpattern 4.4.1 and smd_lately 0.30

At first i thought it was related to the fact that i’m calling the plugin on a mega menu, wich is inside a <txp:section_list/> form.

But then i’ve tried outside the menu, on the sidebar of a page and still have the same issue for both problems (Bizarre number of posts limit and section parameter returning nothing, just blank code)

The code itself has nothing special:

In the megamenu:
<txp:smd_lately by="" limit="6" form="generic-module"/>
Returns 2 articles

<txp:smd_lately by="" limit="6" form="generic-module" section='<txp:section/>'/>
Returns blank and so does…

<txp:smd_lately by="" limit="6" form="generic-module" section="economics"/>
And just for the records, when i specify a section the warnings goes away, like the plugin isn’t even loading or something like that.

The “generic-module” module it’s just native textpattern tagging

<li><span class="f-left"><txp:category1 title="1"/></span><p class="f-right"> <p class="f-right"> <txp:permlink> <txp:if_custom_field name="Titulo Pequeno"> <txp:custom_field name="Titulo Pequeno"/> <txp:else/> <txp:title/> </txp:if_custom_field> </txp:permlink> </p> </li>

It’s weird because i’ve being using smd_lately on every single Textpattern website i deal with and never had any problems with it. I’ll will install it on a vanilla sky install and see if it works.

Diagnostic tab it’s all ok and php version is 5.3.8, i’m loggin all hits but they are my own hits only since it’s a test environment…

Last edited by brunodario (2012-05-15 21:22:02)

Offline

#80 2012-05-15 21:29:28

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,844
Website

Re: smd_lately: recently viewed site articles

brunodario

Hmmm, you’re right, nothing weird there. Couple of things to try and nail this down:

  1. add debug="1" (or 2 or 3) to the plugin tag and see if the plugin’s diagnostics output gives you (or me!) any interesting leads.
  2. ensure that your permlink mode has /section in it if you want to limit by section.

I’d love to get to the bottom of this one.


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