Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2012-10-31 17:21:41

feragnoli
Member
From: the hague
Registered: 2005-02-10
Posts: 150

Re: aks_article : Extended article_custom tag

hello,
many thanks for your work and your plugins.

is it possible to prevent the carousel feature from loading old articles as ‘next’ ones?
right now, if the current article is the last article posted, the carousel produces this:

  • prev_article-1
  • prev_article
  • current_article
  • next_article ( last article posted )
  • next_article+1 ( oldest article posted )

thanks you.


what was that again…?

Offline

#12 2013-10-23 08:28:49

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: aks_article : Extended article_custom tag

Changes aks_article v0.2.7:

  • New experimental attribute list allow to generate a list of articles with minimal impact on mysql. This support ONLY <txp:title /> and <txp:permlink /> tags inside form.
    • New experimental attribute listfield used with list attribute.
  • Attribute time added new value 'all' equivalent as time="any"' and expired="1" (this remove time check condition from sql query)

Background:

Conducted revision their sites, they used a lot of simple lists of related articles. Based on article_custom/aks_article.
I noticed that these lists (sql queries) are not cached in the internal cache mysql.

For sample:

<txp:aks_article section="ua" category2="bus2" limit="50" break=" "><a href="<txp:permlink />"><txp:title /></a></txp:aks_article>

executes the query:

Query_time: 0.014056 Lock_time: 0.000229 Rows_sent: 24 Rows_examined: 253 Rows_affected: 0 Rows_read: 253
Bytes_sent: 1020721 Tmp_tables: 0 Tmp_disk_tables: 0 Tmp_table_sizes: 0
QC_Hit: No Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No
Filesort: Yes Filesort_on_disk: No Merge_passes: 0
SET timestamp=1382443356;
select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from txp_textpattern as textpattern where Status IN (4) and Posted <= now() and (now() <= Expires or Expires = ’0000-00-00 00:00:00’) and Category2 IN (‘bus2’) and Section IN (‘ua’) order by Posted desc limit 0, 50;

Bytes_sent: 1020721 bytes – This query returns all fields, but really I only need ID,Title,url_title,Section
QC_Hit: No – Do not use the internal cache mysql. Because the query is a function now() and fields type `text`.

New code:

<txp:aks_article section="ua" category2="bus2" limit="50" time="all" list="permlink" break=" " />

Query_time: 0.000056 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 Rows_affected: 0 Rows_read: 0
Bytes_sent: 1776 Tmp_tables: 0 Tmp_disk_tables: 0 Tmp_table_sizes: 0
QC_Hit: Yes Full_scan: No Full_join: No Tmp_table: No Tmp_table_on_disk: No
Filesort: No Filesort_on_disk: No Merge_passes: 0
SET timestamp=1382443818;
select ID,Title,url_title,Section,Category1,Category2 from txp_textpattern as textpattern where Status IN (4) and Category2 IN (‘bus2’) and Section IN (‘ua’) order by Posted desc limit 0, 50;

Last edited by makss (2016-01-16 19:00:26)


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#13 2013-10-29 10:23:37

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: aks_article : Extended article_custom tag

Changes aks_article v0.2.8:

  • Shorthand for list attribute

Example:

<txp:aks_article category2="abc" limit="40" sort="title" wraptag="ul" break="li" time="all" list="permlink_nf" />
equivalent shorthand:
<txp:aks_article category2="abc" limit="40" sort="title" list="all_ul_permlink_nf" />

Last edited by makss (2016-01-16 19:00:48)


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#14 2014-01-10 10:09:07

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 259
Website

Re: aks_article : Extended article_custom tag

Hello,

actually I use the orphaned plugin chh_article_custom. aks_article could be an interesting alternative. The problem is, that I use in chh_article_custom some functions aks_article seems to miss. Am I right?

For example:

<txp:chh_article_custom sortby="custom_7" sortdir="desc" wraptag="ul" break="li" limit="1" offset="0" section="artikel" listform="eins" time="-7 days" />

This means show me the first article of the last seven days ordered by custom field 7 in an unordered list, with no offset.

or a second example

 <txp:chh_article_custom sortby="custom_7" sortdir="desc" wraptag="ul" break="li" limit="1" offset="1" section="artikel" listform="zwei_und_drei" time="-365 days,-31 days" />

Show me the second article in a list sorted by custom_7 older than one month and not older than one year.

Custom Field 7 is a number ….

Offline

#15 2014-01-10 10:41:11

etc
Developer
Registered: 2010-11-11
Posts: 3,359
Website

Re: aks_article : Extended article_custom tag

whocarez wrote #277986:

The problem is, that I use in chh_article_custom some functions aks_article seems to miss. Am I right?

No, they are just called differently. Try

<txp:aks_article sort="custom_7 desc" wraptag="ul" break="li" limit="1" offset="1" section="artikel" form="zwei_und_drei"
	where="DATEDIFF(Posted, NOW()) BETWEEN -365 AND -31" />

Last edited by etc (2014-01-10 10:41:32)

Offline

#16 2014-01-10 11:28:04

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 259
Website

Re: aks_article : Extended article_custom tag

wow, cool … I`ll try it …

Offline

#17 2014-01-10 13:47:10

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 259
Website

Re: aks_article : Extended article_custom tag

ok, it works perfect, thanks again …
another question whether I can use aks_article to replace also chh_related_articles wich shows related articles by keywords …

this one doesn’t work: <txp:aks_article where='Keywords LIKE %<txp:keywords />%' limit="9" form="artikel-liste-text" />

At the moment I use <txp:chh_related_articles relation="category,keywords" limit="9" form="artikel-liste-text" />

any hint?

Offline

#18 2014-01-10 14:07:19

etc
Developer
Registered: 2010-11-11
Posts: 3,359
Website

Re: aks_article : Extended article_custom tag

whocarez wrote #278004:

this one doesn’t work: <txp:aks_article where='Keywords LIKE %<txp:keywords />%' limit="9" form="artikel-liste-text" />

You must quote the pattern in LIKE clause somehow (to test):

<txp:aks_article where='Keywords LIKE "%<txp:keywords />%"' limit="9" form="artikel-liste-text" />

but this will restrict the list to the articles with keywords substring of <txp:keywords />. Check if -related_articles keywords='<txp:keywords />' attribute does the job for you.

Last edited by etc (2014-01-10 14:40:29)

Offline

#19 2014-01-10 15:19:36

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 259
Website

Re: aks_article : Extended article_custom tag

ah, sometimes it is worth to look in the instruction :-)

anyway, the following lines make the job:

<txp:variable name="first_keyword" value='<txp:php>$text=explode(",",keywords());echo $text[0];</txp:php>' />
<txp:variable name="second_keyword" value='<txp:php>$text=explode(",",keywords());echo $text[1];</txp:php>' />
<txp:variable name="third_keyword" value='<txp:php>$text=explode(",",keywords());echo $text[2];</txp:php>' />
<txp:aks_article where='ID <> "<txp:article_id />" AND Keywords LIKE "%<txp:variable name="first_keyword" />%" OR "%<txp:variable name="second_keyword" />%" OR "%<txp:variable name="third_keyword" />%"' wraptag="" break="" limit="9" form="artikel-liste-text" section="artikel" />

Maybe there exists a cleverer solution …

Offline

#20 2014-01-11 23:02:23

etc
Developer
Registered: 2010-11-11
Posts: 3,359
Website

Re: aks_article : Extended article_custom tag

whocarez wrote #278011:

anyway, the following lines make the job:

<txp:variable name="first_keyword" value='<txp:php>$text=explode(",",keywords());echo $text[0];</txp:php>' />...

Maybe there exists a cleverer solution …

I doubt it works as intended — all variables save first_keyword will be ignored. If you don’t want to use plugins keywords attribute (why?), you can try to mimic it as follows:

<txp:variable name="keywords"
	value='<txp:php>$text=do_list(doSlash(keywords()));
	echo implode("'', Keywords) OR FIND_IN_SET(''", $text);</txp:php>' />

<txp:aks_article wraptag="" break="" limit="9" form="artikel-liste-text" section="artikel"
	where='ID <> "<txp:article_id />" AND ( FIND_IN_SET(''<txp:variable name="keywords" />'', Keywords) )' />

Edit: parentheses

Last edited by etc (2014-01-12 10:51:49)

Offline

Board footer

Powered by FluxBB