Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2014-04-30 00:58:33

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Re: aks_article : Extended article_custom tag

Thank you for your reply, makss. I went back in and tried it again and it is working as it should. Now I see that my browser’s memory cache isn’t refreshing my custom article list in the write tab. (I’m using aks_custom in a page form that is displayed within the write page txptip ) After clearing the cache, articles are correctly sorted by position. I’m sorry to have bothered you with this question!

Offline

#26 2017-04-13 16:36:04

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: aks_article : Extended article_custom tag

Hello, has someone get this plugin working together with textpattern 4.6.2?
<txp:aks_article sort="custom_7 desc" wraptag="article" break="" limit="1" offset="0" section="article" form="some_form" where="DATEDIFF(NOW(),Posted) <= 7" />

Has no output and in debug mode I don’t see any notice or warning. The same code works fine in 4.5.7.

Last edited by whocarez (2017-04-13 16:44:04)

Offline

#27 2017-04-13 20:27:22

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: aks_article : Extended article_custom tag

This problem is also related to the Textpattern Error Unknown column 'NULLDATETIME'

if (!$expired) {	$time .= " and (now() <= Expires or Expires IS NULL)"; }

instead of

if (!$expired) {	$time .= " and (now() <= Expires or Expires = ".NULLDATETIME.")"; }

solves the problem.

Offline

#28 2017-04-13 21:08:00

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: aks_article : Extended article_custom tag

@makss
A nice feature would be to exclude articles by article id and also an export of the listed article ids into a variable to use it in a second run for excluding articles.

Offline

#29 2017-04-15 07:35:14

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

Re: aks_article : Extended article_custom tag

@whocarez
Thanks for the bug report, in the near future I will fix it and add new features.


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

#30 2017-04-15 17:22:31

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: aks_article : Extended article_custom tag

ok, thank you, waiting for a new version :-)

Offline

#31 2017-04-17 11:05:59

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

Re: aks_article : Extended article_custom tag

New version aks_article v0.3.1:

  • Txp 4.6 fix and Using SQL caching capabilities. Txp 4.6+
  • Added exclude attribute
  • Added aks_article_ids Txp variable – This is the ID of the articles that were displayed.
Show 3 random articles:
<txp:aks_article form="some_form" limit="3" sort="rand()" />
.
Show the rest of the article, excluding those already shown:
<txp:aks_article form="some_form" exclude='<txp:variable name="aks_article_ids"/>' />

Last edited by makss (2017-04-17 11:23:59)


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

#32 2017-04-17 11:58:07

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: aks_article : Extended article_custom tag

thanks for this new version …

Got this error message in debug with now article shown after removing the ‘@’ before aks_article_doArticles :


Tag error: <txp:aks_article sort="custom_7 desc" wraptag="" break="" offset="1" limit="1" section="article" form="default_others_article" where="DATEDIFF(NOW(),Posted) <= 7" exclude="<txp:variable name='aks_article_ids' />" /> ->  Notice: Undefined offset: 1 while parsing form None on page default

textpattern/lib/txplib_misc.php(1782) : eval()'d code:39 aks_article_doArticles()
aks_article()
textpattern/vendors/Textpattern/Tag/Registry.php:83 call_user_func()
textpattern/lib/txplib_publish.php:514 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_misc.php(1782) : eval()'d code:69 processTags()
adi_if_content()
textpattern/vendors/Textpattern/Tag/Registry.php:83 call_user_func()
textpattern/lib/txplib_publish.php:514 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_publish.php:463 processTags()
textpattern/lib/txplib_misc.php(1782) : eval()'d code:83 parse()

The freshest article in this test environment is 11 days old.
In my form I build a top 3 of read articles with the help of aks_article, adi_if_content and dzd_counter_view. So aks_article should look first within the articles of the last week. If there is no article, than take the articles within the last month, if there is also no result take these within the last year. That’s the first run.
In the second run should aks_article look for the second most read article within the last week, month or year excluding the top 1 article from the first run. And in the end the third run, exclude the top 1 and top 2 articles. Maybe it is a little bit to complicated, but sometimes I do nothing on this website for more than a month, but I want to have a top 3 also in this time. But I cannot take the top 3 from the last year, because in this case the fresher ones are ignored, because of a lower read number.
Under some circumstances the the positions of some articles are the same, so one article can be doubled in this top 3, that’s why I want to exclude the earlier listed ones.
So, thats the “problem” in short.

Last edited by whocarez (2017-04-17 11:58:52)

Offline

#33 2017-04-17 12:04:31

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

Re: aks_article : Extended article_custom tag

exclude="<txp:variable name='aks_article_ids' />" – Embedded tag, single quotes are needed: exclude='<txp:variable name="aks_article_ids" />'


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

#34 2017-04-17 12:15:13

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: aks_article : Extended article_custom tag

hm, I still get no output or better only output for the top 1 and the top 2

Tag error: <txp:aks_article sort="custom_7 desc" wraptag="article" break="" limit="1" section="article" form="default_first_article" where="DATEDIFF(NOW(),Posted) <= 7" /> ->  Notice: Undefined offset: 1 while parsing form None on page default

textpattern/lib/txplib_misc.php(1782) : eval()'d code:39 aks_article_doArticles()
aks_article()
textpattern/vendors/Textpattern/Tag/Registry.php:83 call_user_func()
textpattern/lib/txplib_publish.php:514 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_misc.php(1782) : eval()'d code:69 processTags()
adi_if_content()
textpattern/vendors/Textpattern/Tag/Registry.php:83 call_user_func()
textpattern/lib/txplib_publish.php:514 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_publish.php:463 processTags()
textpattern/lib/txplib_misc.php(1782) : eval()'d code:83 parse()

Tag error: <txp:aks_article sort="custom_7 desc" wraptag="" break="" offset="1" limit="1" section="article" form="default_others_article" where="DATEDIFF(NOW(),Posted) <= 7" exclude='<txp:variable name="aks_article_ids" />' /> ->  Notice: Undefined offset: 1 while parsing form None on page default

textpattern/lib/txplib_misc.php(1782) : eval()'d code:39 aks_article_doArticles()
aks_article()
textpattern/vendors/Textpattern/Tag/Registry.php:83 call_user_func()
textpattern/lib/txplib_publish.php:514 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_misc.php(1782) : eval()'d code:69 processTags()
adi_if_content()
textpattern/vendors/Textpattern/Tag/Registry.php:83 call_user_func()
textpattern/lib/txplib_publish.php:514 Textpattern\Tag\Registry->process()
textpattern/lib/txplib_publish.php:463 processTags()
textpattern/lib/txplib_misc.php(1782) : eval()'d code:83 parse()

and in the source code of the rendered page I see this instead of the third article:
<txp:aks_article sort="custom_7 desc" wraptag="" break="" offset="2" limit="1" section="article" form="default_others_article" where="DATEDIFF(NOW(),Posted) <= 7" exclude='4609' />

Last edited by whocarez (2017-04-17 12:17:58)

Offline

#35 2017-04-17 17:32:30

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

Re: aks_article : Extended article_custom tag

whocarez wrote #305367:

In my form I build a top 3 of read articles with the help of aks_article, adi_if_content and dzd_counter_view. So aks_article should look first within the articles of the last week. If there is no article, than take the articles within the last month, if there is also no result take these within the last year. That’s the first run.
In the second run should aks_article look for the second most read article within the last week, month or year excluding the top 1 article from the first run. And in the end the third run, exclude the top 1 and top 2 articles. Maybe it is a little bit to complicated, but sometimes I do nothing on this website for more than a month, but I want to have a top 3 also in this time. But I cannot take the top 3 from the last year, because in this case the fresher ones are ignored, because of a lower read number.
Under some circumstances the the positions of some articles are the same, so one article can be doubled in this top 3, that’s why I want to exclude the earlier listed ones.
So, thats the “problem” in short.

Can solve this problem using the IF operator in MySQL.

  • The first Top range is last week: DATEDIFF(NOW(),Posted)<=7 – Let’s set this range to 0.
  • Second Top Month: DATEDIFF(NOW(),Posted)<=30 – Assign the value 1
  • Third Annual Top: DATEDIFF(NOW(),Posted)<=365 – value 2
  • All the rest, more than one year – value 3

Now we need to sort by the range number (the smaller the number, the more priority), and then by the number of views (custom_7 desc).

Outputs the Top 3 in one block:
<txp:aks_article sort="IF(DATEDIFF(NOW(),Posted)<=7, 0, IF(DATEDIFF(NOW(),Posted)<=30, 1, IF(DATEDIFF(NOW(),Posted)<=365, 2, 3))), custom_7 desc" wraptag="" break="" section="article" form="default_others_article" limit="3" />

If you want to display articles from the Top in different places of the template, then use the Txp variables:

Set variables:
<txp:aks_article sort="IF(DATEDIFF(NOW(),Posted)<=7, 0, IF(DATEDIFF(NOW(),Posted)<=30, 1, IF(DATEDIFF(NOW(),Posted)<=365, 2, 3))), custom_7 desc" section="article"  limit="3">
	<txp:variable name='top_result_<txp:aks_article_count />'>
		<txp:aks_article_count />: <txp:title />
	</txp:variable>
</txp:aks_article>
...
Show first: <txp:variable name="top_result_1" />
Second: <txp:variable name="top_result_2" />
The third result: <txp:variable name="top_result_3" />

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

#36 2017-04-18 11:51:28

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: aks_article : Extended article_custom tag

Wow, impressive!! That simplifies the code considerably. Big thanks!

So for now I use it like that, because the first article uses another form for title, article_image etc.


<txp:aks_article sort="IF(DATEDIFF(NOW(),Posted)<=7, 0, IF(DATEDIFF(NOW(),Posted)<=30, 1, IF(DATEDIFF(NOW(),Posted)<=365, 2, 3))), custom_7 desc" section="article"  limit="3">
	<txp:variable name='top_result_<txp:aks_article_count />'>
		<txp:article_id />
	</txp:variable>
</txp:aks_article>

            <div class="general-art item-actual">
<!-- Nr.1 -->
                <txp:aks_article id='<txp:variable name="top_result_1" />' form="default_first_article" />
            </div>

            <div class="others-art item-actual">
<!-- Nr.2 -->
                <txp:aks_article id='<txp:variable name="top_result_2" />' form="default_others_article" />
<!-- Nr.3 -->
                <txp:aks_article id='<txp:variable name="top_result_3" />' form="default_others_article" />
            </div>

Offline

Board footer

Powered by FluxBB