Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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: 70
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,216

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: 3,580
Website

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: 9,120
Website

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.

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: 9,120
Website

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.

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: 234
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