Skip to content

Latest commit

 

History

History
196 lines (154 loc) · 12.5 KB

themes.md

File metadata and controls

196 lines (154 loc) · 12.5 KB

WordPress to Textpattern theme

Txp theme structure

Description

Textpattern stores code chunks as pages and forms in its database. Forms allow to customize the output of some Txp tags (functions) such as article, comments, search_input, etc.; they also provide a way to store other custom templates parts, or overriding forms (post formats). which can be output via the output_form tag. Pages are used to include forms and/or static contents.

  • template parts are defined through custom forms
  • post formats can be defined via custom article forms and used as overidding_forms in the admin Write panel

Default theme filetree

themes
+-- my_theme
|   +-- pages
|   |   +-- archive.txp (Page example)
|   |   +-- default.txp (default page display)
|   |   +-- error_default.txp (default error page display)
|   |   +-- …
|   +-- forms
|   |   +-- article
|   |   |   +-- default.txp (default article display used by the 'article' tag)
|   |   |   +-- article_listing.txp (default article list display used by the 'article' tag)
|   |   |   +-- search_results.txp (default search results display used by the 'search_results' tag)
|   |   |   +-- …
|   |   +-- comment
|   |   |   +-- comment_form.txp (default comment form display used by the 'comments_form' tag)
|   |   |   +-- comments.txp (default comments display used by the 'comments' tag)
|   |   |   +-- comments_display.txp (default comment display used by the 'comment' tag)
|   |   |   +-- popup_comments.txp (default comments popup display)
|   |   |   +-- …
|   |   +-- file
|   |   |   +-- files.txp (default file display used by the 'file_download' tag)
|   |   |   +-- …
|   |   +-- link
|   |   |   +-- plainlinks.txp (default links display used by the 'linklist' tag)
|   |   |   +-- …
|   |   +-- misc
|   |   |   +-- images.txp (not defined as the default form of any tag)
|   |   |   +-- search_input.txp (default search form display used by the 'search_input' tag)
|   |   |   +-- …
|   +-- styles
|   |   +-- default.css (not defined as the default style of any tag)
|   |   +-- …
+-- …

Introduction to Txp tags

WP vs Txp tags

WordPress templates contain HTML and PHP.
While Textpattern templates can also contain some PHP code, they are usually mainly composed of HTML and Txp tags. Textpattern tags are easy to use and make themes really easy to read and modify. You don't even need repeated <?php ?> tags to switch between HTML and PHP.

Conditional contents

WordPress uses has_ and in_ prefixed functions to include conditional contents.

<?php if ( in_category( '3' ) ) : ?>
    <div class="post-cat-three">
<?php else : ?>
    <div class="post">
<?php endif; ?>

Textpattern use conditional tags prefixed by if_.

<txp:if_category name="3">
    <div class="post-cat-three">
<txp:else />
    <div class="post">
</txp:if_article>

From the introduction of short-tags in Txp v4.7+, you could even make it shorter.
And in case there is not conditional tag for your need, the recent evaluate tag allows to check any tag output! It also does a lot more…

Tags reference

WP functions to Txp tags [a→z]

_

B

C

G

H

I

L

N

P

S

T

W