Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-05-23 09:35:44

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Before/after 4.7 primer

Textpattern 4.7 introduces important new features (like themes, global attributes etc) that deserve each a separate discussion. But it also offers its users easier ways to achieve some common tasks that we briefly describe here.

Don’t pgonly anymore

We need to display previous/next page links before the articles list:

Before
<txp:article pgonly="1" />
<txp:newer /> - <txp:older />
<txp:article />
After
<txp:newer /> - <txp:older />
<txp:article />

Say not to lame <txp:else />

We need to hide some text under some condition, say in some section:

Before
<txp:if_section name="about">
<txp:else />
    Not about section.
</txp:if_section>
After
<txp:if_section not name="about">
    Not about section.
</txp:if_section>

Be valueless

Most of Boolean attributes 1 values can be skipped now:

Before
<txp:section link="1" title="1" />
After
<txp:section link title />

Adopt <txp:evaluate />

We need to display a breadcrumb only when corresponding articles exist:

Before
<txp:variable name="articles" value='<txp:article />' />
<txp:if_variable name="articles" value="">
<txp:else />
    <txp:variable name="articles" />
    <txp:breadcrumb />
</txp:if_variable>
After
<txp:evaluate test="article">
    <txp:article />
    <txp:breadcrumb />
</txp:evaluate>

Enjoy wraptag new powers

We need to append a class pulled from some custom field:

Before
<txp:if_custom_field name="class"> class="<txp:custom_field name="class" />"</txp:if_custom_field>
After
<txp:custom_field name="class" wraptag=' class="<+>"' />

What else?

Please feel free to share if you discover something new!

Offline

#2 2018-05-23 10:49:00

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,529
Website GitHub Twitter

Re: Before/after 4.7 primer

Yeah really cool features for devs!

Thanks guys for the hard work.

Offline

#3 2018-09-10 19:35:47

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Before/after 4.7 primer

Grouping articles (and other lists) is straightforward in 4.7:

<txp:article break="div" breakclass="group" breakby="2">
    <article><txp:title /></article>
</txp:article>

Offline

Board footer

Powered by FluxBB