Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Not This Section

// description of your code here

<txp:if_section name="notthissection">
<!-- do nothing -->
<txp:else />
blah blah
</txp:if_section>

Serving links to multilingual pages

http://forum.textpattern.com/viewtopic.php?id=12371

Let’s assume you want to have two sets of pages which would be crosslinked with links like “see this page in [another language]”. Set custom fields for the languages you want to support, name them, for example eng and ukr (for English and Ukrainian).

Write articles for those languages and assign them links of their sibling articles on the other language, say, you have an article in English with permanent link “/about/my-dog” and you have the same article in Ukrainian with permanent link “/about/my-dog-ukr”, then set “/about/my-dog” to the custom field “eng” in the article on Ukrainian and “/about/my-dog-ukr” to the custom field “ukr” in the article on English.

Then in the article form you use write a code similar to the following:

<txp:if_custom_field name=“eng”>
<a href=”<txp:custom_field name=“eng” />”>this page in english</a>
</txp:if_custom_field>

<txp:if_custom_field name=“ukr”>
<a href=”<txp:custom_field name=“ukr” />”>this page in ukrainian</a>
</txp:if_custom_field>


That’s it! When it’s English link to Ukrainian article will be shown up and vice versa.
It’s just a basic example to give you an idea, hope it helps.

Article list from same category / section as current article

From a post on the Textpattern support forums.

<ul><txp:asy_wondertag><txp:article_custom limit="9999" form="listarticles" section="<txp:section />" category="<txp:category1 />" /></txp:asy_wondertag></ul>

Return a message on blank search form submit

From a post on the Textpattern support forums.

<txp:php> if(gps('q') == '') echo 'Hey, remember to search something!'; </txp:php>