Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 209
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: 12,460
Website GitHub

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.

Hire 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: 12,460
Website GitHub

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.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#81 2012-05-15 21:46:36

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

Re: smd_lately: recently viewed site articles

Stef

Debugging with no “section” parameter:

select name from txp_section where 1=1

++ smd_lately RULES ++

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 NOT REGEXP \'^/(default|economia|marcadores|mineracao-e-metalurgia|search|sustentabilidade)/?$\'',
)

SELECT count(page) as popularity, page, MAX(time) as time FROM txp_log WHERE 1=1 AND page NOT LIKE '%nacionalizacao-da-ypf-nao-e-a-solucao-para-a-crise-energetica-da-argentina' 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 NOT REGEXP '^/(default|economia|marcadores|mineracao-e-metalurgia|search|sustentabilidade)/?$' AND status = 200 GROUP BY page ORDER BY time desc

select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where url_title IN ('corte','anglo-american-participara-da-reatech','mineracao-e-metalurgia','economia','index.php','protecao-chinesa-das-terras-raras-gera-discussao-na-omc','sampler_169x84.jpg','carregando.gif','enge_de_minas_news_footer.jpg','bt_buscar.jpg') AND Posted < NOW()

Debuggin with specific section=’<txp:section>’ parameter:

++ smd_lately RULES ++

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 \'/mineracao-e-metalurgia%\' AND page NOT REGEXP \'^/mineracao-e-metalurgia/?$\')',
)

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=%

Hope it helps you so you can help me! Thx in advance…

{Edited to add bc.. for better code display. – Uli}

Last edited by uli (2012-05-15 21:57:53)

Offline

#82 2012-05-17 11:45:54

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

Re: smd_lately: recently viewed site articles

Stef, any news on this? I still haven’t found a solution and ironincally this a a website that uses this plugin a lot.

One thing i thought may be causing problems it’s that i’ve tested with very few articles published, i’m including some more now and performing some tests.

Offline

#83 2013-04-02 22:09:02

visualpeople
Member
From: Corvallis, Oregon - USA
Registered: 2005-11-16
Posts: 73
Website

Re: smd_lately: recently viewed site articles

Is there a way to limit the smd_lately plugin to just a certain category (as you would an article_cusom tag, for instance)?

What we’re trying to (essentially) do:

	<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"/>
				<txp:article_custom sort="popularity" section="XYZ" category='<txp:category/>' form="subnav" sort="title asc" wraptag="ul"/>
		</li>				
	</txp:category_list>

But obviously replacing the article_custom tag with:
<txp:smd_lately by="" sort="popularity" section="XYZ" category='<txp:category/>' form="subnav" wraptag="ul"/>
Doesn’t work since there’s no “category” option for smd_lately… and leaving the category blank displays ALL articles in the whole section (not even limiting to just the parent ABC category).

Any thoughts on how we could trick smd_lately into only displaying articles in the current category being shown by txp:category_list?

Offline

#84 2013-04-02 22:28:14

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,316

Re: smd_lately: recently viewed site articles

Ryan, this plugin has a form attribute. So you can use it to collect txp:article_id’s and inject these into/as your article_custom’s id attribute (tag nesting). It might be a little too twisted for the efficiency purist but it could work. (Ooompf, does ID overrule category, does a combination result in an intersection? Too tired ATM.)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#85 2013-04-03 19:05:26

etc
Developer
Registered: 2010-11-11
Posts: 5,680
Website GitHub

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

#86 2013-05-03 13:14:44

clivewalker
Member
From: Horsham UK
Registered: 2004-07-19
Posts: 26
Website

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

#87 2013-05-03 13:38:41

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,460
Website GitHub

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:

  1. Keep a reasonably low value for the Logs expire after how many days preference.
  2. 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.
  3. Use smd_lately’s cache_time attribute to reduce the number of times the table is hit. If you set it to cache_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 the cache_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.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#88 2013-05-03 15:11:26

clivewalker
Member
From: Horsham UK
Registered: 2004-07-19
Posts: 26
Website

Re: smd_lately: recently viewed site articles

Many thanks, that’s very useful

Offline

#89 2014-03-13 20:49:39

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,460
Website GitHub

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.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#90 2014-03-13 20:53:34

kees-b
Member
From: middelburg, nl
Registered: 2004-03-03
Posts: 235
Website

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 or exclude attributes. Thanks, kees-b.

thanks to you!!

Offline

Board footer

Powered by FluxBB