Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

robhert
Member
From: Perú
Registered: 2007-04-27
Posts: 206
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: 11,419
Website GitHub

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: 206
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: 206
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: 11,419
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.

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: 11,419
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.

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,306

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

Board footer

Powered by FluxBB