aks_article

Current version: 0.3.2

Support forum: English
Download: aks_article

aks_article – Extended article_custom tag

download link / homepage / forum

Summary

The plugin is based on a rewritten core functions article_custom(), parseArticles(), doArticles()

Change log

v0.1 plugin was writen for testing Feature Idea <txp:else />
v0.2+ plugin is completely rewritten

2012-05-22 Changes v0.2.4:

  • optimize code, SQL, memory usage.
  • added support <txp:else />
  • added attributes category1, category2, where
  • extend attribute status to status list

2012-08-31 Changes v0.2.5:

  • Inside form:
    • zebra-lines feature, useful for zebra-coloring lines
    • active-line feature, useful for set class=“active”
    • get current line number
  • Return txp:variables:
    • displayed articles
    • rest articles (limit – displayed), useful for second call to aks_article
    • zebra_next count for second zebra call

2012-09-04 Changes v0.2.6:

  • Prev/Next carousel feature – show nearest articles. Attribute carousel
  • Multi-column feature, attributes: column, columntag, columnclass
  • Other attributes: hideself, wrapid, breakclass

2013-10-22 Changes v0.2.7

  • Attribute time added new value 'all' equivalent as time="any"' and expired="1" (this remove time check condition from sql query)
  • 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.

2013-10-29 Changes v0.2.8

  • Shorthand for list attribute

2014-03-13 Changes v0.2.9

  • Added search feature (based on MySQL FULLTEXT search) – useful for get related articles

2016-07-02 Changes v0.3

  • Txp 4.6 fix

2017-04-17 Changes 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.

Tags

<txp:aks_article /> is a single or a container tag

attributesdefaultsampledescription
formdefaultsome_formsame as article_custom
categorycat1,cat2for category1 or category2
category1cat1,cat2category1 IN('cat1','cat2')
category2cat1,cat2category2 IN('cat1','cat2')
wherecategory1<>'' or title like '%sport%'SQL where. WARNING not slashed, safety use it!
sectionsec1,sec2
excerptedy
authorauthor1,author2
sorttitle asc
month
keywords
expired
id1,7,33,12
exclude2,17,71
timepastOne of: past, any, future, all
status4hidden,5,liveAllow any status list(text or numeric, draft, hidden…) safety use it!
allowoverride01
hideself01
offset0
limit10999
searchword1 word2Find this and sort articles by MySQL search scope
searchfieldTitle,BodyFor advanced, see below.
zebra3zebra-coloring, used with <txp:aks_article_zebra />
zebra_nextfor second call aks_article, see examples
carousel01prev-1/prev/current/next/next+1 (limited by limit attribute)
list11 – turn on; permlink or permlink2 – turn on and set a fixed form. See below.
listfieldFor advanced, see below. WARNING not slashed, safety use it!
column13multi-column output
columntagdivtd
columnclass
wraptag
wrapid
classwrap class
break
breakclass
label
labeltag

This tag returns <txp:variables />

  • <txp:variable name="aks_article_count" /> – Displayed articles
  • <txp:variable name="aks_article_rest" /> – Rest articles (limit – displayed), useful for second call to aks_article
  • <txp:variable name="aks_article_zebra_next" /> – Next count for second zebra call
  • <txp:variable name="aks_article_ids" /> – The ID of the articles that were displayed.

Attribute `list`

This attribute is used to increase performance when building simple lists of articles. I also recommend setting the attribute time="all"

AttribyteSet `fixed form`Set other attribute
list="1"Use inline form or form in `form` attributenone
list="permlink" <a href="<txp:permlink />"><txp:title /></a>none
list="permlink_nf" <a href="<txp:permlink />" rel="nofollow"><txp:title /></a>none
list="permlink2" <txp:permlink><txp:title /></txp:permlink>none
list="all_permlink" <a href="<txp:permlink />"><txp:title /></a> time="all"
list="ul_permlink" <a href="<txp:permlink />"><txp:title /></a> wraptag="ul" break="li"
list="all_ul_permlink" <a href="<txp:permlink />"><txp:title /></a> time="all" wraptag="ul" break="li"

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" />

Attribute `listfield`

This attribute is used only in combination with the attribute `list`.
You can add additional fields from the table textpattern. By default, the query returns the following fields: ID, Title, url_title, Section, Category1, Category2
Warning, the name fields are case sensitive.

Example:

<txp:aks_article form="someform" time="all" list="1" listfield="Image,qwerty" />

where:
Image – field from table textpattern
qwerty – Named custom field `custom_2`

This query returns the following fields: ID, Title, url_title, Section, Category1, Category2, Image, custom_2

Attribute `search`

Find related articles by search in Title, Body fields.

<txp:aks_article hideself="1" search='<txp:keywords />' wraptag="ul" break="li" limit="20">
	<txp:variable name="aks_article_scope"/>	<txp:title />
</txp:aks_article>

Remark: <txp:variable name="aks_article_scope"/> used only for debug.

Attribute `searchfield`

For advanced ONLY! – need change `textpattern` table.

Find related articles by search in Keywords field.
Importantly: create FULLTEXT index for `textpattern` table. SQL command:

ALTER TABLE `textpattern` ADD FULLTEXT (`Keywords`);

Then you can use the code:

<txp:aks_article hideself="1" search='<txp:keywords />' searchfield="Keywords" wraptag="ul" break="li" limit="20">
	<txp:variable name="aks_article_scope"/>	<txp:title />
</txp:aks_article>

Form tags

<txp:aks_article_zebra /> is a single tag – Used ONLY inside form

attributesdefaultsampledescription
classsomesimple wrap for lazy: class="some{$zebra}"

it not attributes then return $zebra value

<txp:if_aks_article_active /> is a single or a container tag – Used ONLY inside form

attributesdefaultsampledescription
valueclass='active'only single tag attribute, return value

as container tag support <txp:else />

<txp:aks_article_count /> is a single tag – Used ONLY inside form
Return current line number, no attribute available

Example:

<txp:aks_article section="articles" wraptag="ul" break="li">
	<txp:title />
<txp:else />
	Articles not found
</txp:aks_article>

Uses with form

<txp:aks_article section="articles" form="single"><txp:else />
	Articles not found
</txp:aks_article>

Display first `Sticky` article in section if exist, else display some default_welcome_form

<txp:aks_article section='<txp:section />' status="sticky" limit="1">
	<txp:body />
<txp:else />
	<txp:output_form form="default_welcome_form" />
</txp:aks_article>

Example zebra/active/count features

<txp:aks_article category2="mycat" limit="10" sort="title" wraptag="ul" zebra="3">
	<li class="zebra<txp:aks_article_zebra /><txp:if_aks_article_active value=" active" />">
		<txp:aks_article_count  /> <txp:title />
	</li>
</txp:aks_article>
Displayed: <txp:variable name="aks_article_count" /> articles
Limit - Displayed = <txp:variable name="aks_article_rest" /> articles

HTML output:

<ul>
<li class="zebra0"> 1 King</li>
<li class="zebra1"> 2 La Bonne Maison</li>
<li class="zebra2"> 3 Marmaris</li>
<li class="zebra0 active"> 4 Paradise</li>
<li class="zebra1"> 5 Relax</li>
<li class="zebra2"> 6 Sunrise</li>
</ul>
Displayed: 6 articles
Limit - Displayed = 4 articles

and additional call for rest 4 articles with other conditions

<txp:if_variable name="aks_article_rest" />
	<txp:aks_article category2="othercat" zebra="3"
		limit='<txp:variable name="aks_article_rest" />'
		zebra_next='<txp:variable name="aks_article_zebra_next" />'
	 />
</txp:if_variable>

know bug – not stored last zebra color for second call aks_articleFIXED, zebra_next attribute

Example carousel feature

Show nearest articles.

<txp:aks_article limit="7" carousel="1" sort="title" />

output:

  • prev_article-2
  • prev_article-1
  • prev_article
  • current_article
  • next_article
  • next_article+1
  • next_article+2

Example multi-column feature

<txp:aks_article limit="9" column="3" break="br"><txp:aks_article_count /> article</txp:aks_article>

HTML output:

<div>
	1 article<br />
	2 article<br />
	3 article
</div>
<div>
	4 article<br />
	5 article<br />
	6 article
</div>
<div>
	7 article<br />
	8 article<br />
	9 article
</div>

or using <table>

<table><tr>
	<txp:aks_article limit="9" column="3" columntag="td" break="br"><txp:aks_article_count /> article</txp:aks_article>
</tr></table>

HTML output:

<table><tr>
<td>
	1 article<br />
	2 article<br />
	3 article
</td>
<td>
	4 article<br />
	5 article<br />
	6 article
</td>
<td>
	7 article<br />
	8 article<br />
	9 article
</td>
</tr></table>