Miscellaneous category listing. ­ Textpattern CMS

FAQ: Miscellaneous

Why is my database corrupt?


Did Textpattern corrupt my database?
I have a corrupt database table, how do I fix it?


It’s possible for Textpattern’s database to become corrupted. There are several possible causes:

  • A server crash
  • Server hardware failure
  • A MySQL bug

It should not be possible for a user application like Textpattern to damage a MySQL table. (It might be possible for Textpattern to trigger a bug in MySQL, but the fault in that case lies with MySQL).

Occasional database corruption is a risk on shared hosting services, but should be rare. If you’re experiencing frequent corruption problems you should talk to your hosting company, and consider moving to a more reliable service.

In most cases a corrupt table can be repaired easily with little or no permanent damage. Many hosting companies and web hosting control panels provide a quick method of checking and repairing MySQL tables, so check their knowledge base and documentation.

The MySQL manual has a section on checking and repairing tables. TextDrive customers will find phpMyAdmin table repair instructions in the knowledge base.

There is also a Textpattern plugin which can allow you to repair tables in your Textpattern database.

In severe cases a corrupt table can cause data loss. You’ll need to restore a backup if this is the case.

What does the Production Status setting do?


What do the different Production Status settings change?
What are Debug, Testing, Live modes?


Textpattern’s Production Status setting (on admin > preferences) changes several aspects of Textpattern’s behaviour.

Live mode is intended for fully tested production sites.

In Live mode, all internal PHP error messages are suppressed, to eliminate the possibility of leaking sensitive information when something goes wrong. Browser caching features are enabled (4.0.4+ only).

Testing mode should be used when you are making changes to page templates, forms, CSS, configuration settings, or installing or updating plugins.

In Testing mode, PHP error and warning messages will be displayed to the user on public pages. Textpattern will attempt to warn about errors encountered in page templates and forms. Performance information will be included in HTML comments at the bottom of every Textpattern page. Browser caching is disabled.

Debug mode should be used for diagnosing problems in Textpattern templates, plugins and PHP code.

PHP notices will be displayed, in addition to the errors and warnings shown in Testing mode. A complete Tag Trace is included in HTML comments at the bottom of every page, listing all the Textpattern tags encountered on that page. Browser caching is disabled.

It’s normal to see some PHP notices in Debug mode. By itself, a PHP notice is not an indicator that something is wrong; it’s there to help PHP developers find potential problems.

I'm having trouble with a theme


I’m having trouble with the xyz theme..


Please ensure that you’ve followed the instructions that came with the theme.

If there are no instructions, or the instructions are incorrect, please contact the theme’s author.

Did someone hack my site?


I saw a bunch of suspicious hits in the Textpattern log. Is someone trying to hack Textpattern?
I think someone hacked my Textpattern web site!


Attempted security breaches are a daily occurrence at popular web sites. Vandals regularly scan thousands of web sites at a time for known security holes in common software. Only a small fraction of those sites will be vulnerable. On sites that aren’t, the only side effect will usually be a puzzling entry in the traffic log.

In 4 years, there have been no confirmed reports of a successfully exploited security hole in a properly maintained Textpattern web site.

There have been occasional reports of hacked Textpattern sites. In all cases these have been traced to security holes in other applications, or in the web server itself, which were used to take complete control of the user’s account. There is nothing Textpattern can do to defend against security holes in other applications. It’s up to you and your hosting company to keep your applications and server up-to-date with security patches.

The Textpattern development team takes security seriously. We don’t expect our record to remain perfect forever. But we do take a proactive approach to security, regularly auditing the Textpattern source code for potential holes. We don’t wait for the bad guys to find them first.

There are several steps you can take to maximize the security of your web site:

  • Keep your copy of Textpattern up to date.
  • Keep your plugins up to date.
  • Check the admin > diagnostics page for security warnings.
  • If you use other PHP or CGI applications in the same account, like a photo gallery or form mail application, make sure they are maintained and up-to-date.
  • Don’t leave test code or unused PHP/CGI applications on your server.
  • Pay attention to security announcements from your hosting company or server admin.
  • If you maintain your own server, keep it up to date with security patches.

Please note that the Textpattern development team has no control over the quality or security of plugins, add-ons and modifications. It’s up to you to evaluate the security of third-party code.

If you think you have found a security problem in Textpattern, please do not publish sensitive information until the development team has had time to respond. Information about potential security problems should be reported to security at textpattern dot com.

Publishing an article is very slow


There’s a long delay when I click the Publish button. Why?


This is probably caused by a delay in contacting pingomatic.com. A DNS problem on your server is the most likely cause.

You can confirm whether or not this is the problem by turning off “Ping ping-o-matic” and “Ping textpattern.com” in admin > prefs > advanced > publish.

Diagnosing template problems


My page template isn’t displaying what I expect!
My form isn’t displaying the right thing
This tag isn’t working!


We get many requests on the forum for help with template problems. Typically, these are caused by a few simple mistakes or misunderstandings. Below is a brief guide to diagnosing common problems. Please take the time to follow this before asking for help on the forum – it makes it much quicker and easier for others to answer your question.

When a page template doesn’t display the output you expect:

Check for error messages in Testing mode

Set your Production Status to Testing in textpattern > admin > prefs. Live mode suppresses all error messages for security reasons; Testing ensures they are displayed. Reload the page in question and look for errors.

If there is an error associated with a tag, the message should identify that tag.

One common error to check for is Warning: Missing argument 2 for .... This usually indicates a <txp:...> tag that hasn’t been closed properly.

If you see some other error message, search the FAQ and forum for more information, using the main keywords from the error message.

Check for template syntax errors

Some types of syntax errors in <txp:...> tags will cause a silent error. If your page is completely blank, or a large portion of it is empty, examine your template for XML syntax errors like the ones listed in this FAQ entry

Disable plugins

Sometimes a plugin can interfere with Textpattern’s normal operation. If you have plugins installed, try disabling them and see if it fixes the problem. Disable them one at a time and re-test the problem page after each so you can identify the problem plugin.

If you’ve identified a particular plugin as the culprit, the plugin forum is the best starting place to find help.

Double check the documentation

If you’ve isolated the problem to a particular tag, double check its documentation. Make sure the tag really does what you think (common errors include substituting <txp:article_custom /> for <txp:article />, and <txp:if_section> for <txp:if_article_section>), and ensure that the tag name and attribute names are spelled correctly and are lowercase.

Some tags work only in a particular context. Article Form tags, for example, work only in a form that has been loaded by a <txp:article form="myform" /> or <txp:article_custom form="myform" /> tag. Similarly, Comment Form, Link Form and File Download Form tags only work in comment, link, and file download lists respectively. Check the list of Form Related Tags to confirm that you’re using the tag in the right place.

Rule out CSS stylesheet problems

Sometimes a page template can be working perfectly, but appear to be incorrect due to a CSS stylesheet problem. Switch to a neutral stylesheet (perhaps the default style, or an empty stylesheet), and make sure that the unstyled content is correct.

If the stylesheet isn’t being applied to the document at all, or isn’t working in some browsers, view the HTML source of your page and find the CSS URL. Typically it looks like this:

<link rel="stylesheet" href="http://example.com/textpattern/css.php?s=default" type="text/css" media="screen" />

Open that URL (http://example.com/textpattern/css.php?s=default) in your browser and check for obvious problems – a 404 Not Found error, or error messages or other junk at the top or bottom of the stylesheet.

Isolate the problem code

Try simplifying your code and moving it to a fresh template, one small portion at a time. Start with a template that you know to be reliable – the default page is a good choice – and test one small block at a time.

If the problem still occurs on the clean template, you know it’s caused by that particular fragment of code. Try reducing the code to the smallest fragment that still produces the problem – this will make it easier to identify the exact cause.

If the problem occurs on the default page template with no changes at all, it’s not a template problem.

Check the tag trace

In Debugging mode, Textpattern appends a Tag Trace to the HTML output of each page. View the HTML source of the page, and scroll to the bottom. The trace looks something like this:

[Page: default]
<txp:linklist wraptag="p" />
[SQL (0.000112): select Form from `txp_form` where name` = 'plainlinks' limit 1]
[Form: plainlinks]
[SQL (0.000153): select * from txp_link where 1 order by linksort ]

Some things to check:

  • The lines [Page: default] and [Form: plainlinks] indicate that a particular page template or form has been loaded. Make sure it’s the right one.
  • Is the code in question shown in the tag trace at all? If not, it might have been excluded by a conditional tag (<txp:if_...>).
  • If the problem code is in an article form, link form or comment form, is it being loaded? There might not be any articles/links/comments to display at all. The SQL query for the preceeding tag might give you a hint.

Common "How Do I?" questions

Here are some quick answers to common “How Do I?” questions.

How Do I..

…display something only on an individual article page?

Surround it with an txp:if_individual_article tag:

	<!-- displayed on individual article page only -->

…display something only on list (section/front) pages?

Surround it with an txp:if_article_list tag:

	<!-- displayed on list pages only -->

…make an “About” page?

FAQ: Managing Static Pages

…make a reusable sidebar, header or footer?

With the txp:output_form tag.

FAQ: How do I reuse chunks of HTML?

…show a list of recent articles or comments in a sidebar?

With the txp:recent_articles or txp:recent_comments tags.

For more control over a list of recent articles, use txp:article_custom instead.

FAQ: How do I change the output of txp:recent_articles?

…show a short list of articles or article links in a sidebar?

For simple lists, the recent_articles tag might do what you want (see above).

To list articles from a specific section or category, use the txp:article_custom tag. Create an article form containing only the tags you want, for example:

<h4><txp:permlink><txp:title /></txp:permlink></h4>

<txp:excerpt />

Then use a tag like <txp:article_custom limit="5" form="myformname" /> in your sidebar.

…show a short version of articles with a “read more..” link?

Use something like this in your article form:

	<!-- excerpt only -->
	<txp:excerpt />
	<txp:permlink>read more..</txp:permlink>
<txp:else />
	<!-- full article body -->
	<txp:body />

FAQ: How do I show only an excerpt in article lists?

Excerpts automatically generated from the article body are possible through plugins.

…break an article list into columns, or insert ads between certain articles in a list?

Use the limit, offset and pageby attributes of txp:article:

<txp:article limit="3" pageby="10" />

<!-- column break or advertisement -->

<txp:article limit="7" offset="3" pageby="10" />

Textpattern Support Forum: txp:article pageby attribute

…supply a special layout to the first article on a page?

Use the txp:if_first_article tag in your article form:

	<!-- display the entire first article -->
	<txp:body />
<txp:else />
	<!-- display the excerpt only for subsequent articles -->
	<txp:excerpt />

…apply a special layout to articles from a particular section when shown on the front page?

Use the txp:if_article_section tag in your article form:

<txp:if_article_section name="linklog">
	<!-- "linklog" section only -->
	<div class="linklog"><txp:body /></div>
<txp:else />
	<!-- all other sections -->
	<txp:title />

	<txp:body />

…apply a special layout to articles from a particular category?

Use the txp:if_article_category tag in your article form:

<txp:if_article_category name="national">
	<!-- "national" category only -->
	<div class="linklog"><txp:excerpt /></div>
<txp:else />
	<!-- all other categories -->
	<txp:title />
	<txp:body />

…show a unique intro paragraph on each section page?

Post a “Sticky” article in each section containing the paragraph for that section, and display it with a <txp:article status="sticky" /> tag.

FAQ: How do I keep a post at the top of the page?

…show the same intro paragraph on more than one section page?

Post a “Sticky” article containing the text, and display it with the tag <txp:article_custom id="123" />, where 123 is the ID number of the sticky article. Enclose it with the <txp:if_article_list> tag if necessary.

FAQ: How do I keep a post at the top of the page?

…show a unique banner image or similar on a particular section page?

If the page layout for each section is to be identical except for a small element, you should probably share the same page template between all sections, and use the txp:if_section tag to selectively display variations:

<txp:if_section name="weather">
	<img src="/images/cloud.jpg" />

<txp:if_section name="sport">
	<img src="/images/cricket.jpg" />

<!-- etc -->

…add a stylesheet for printing?

Create a new style named “print”, and add this to the <head> portion of your page template:

<txp:css format="link" media="print" n="print" />

…display a random article, or a link to a random article?

Put this in your page template:

<txp:article_custom sort="rand()" limit="1" form="random" />

..and create an article form named “random” containing the appropriate article tags, e.g:

<txp:permlink><txp:title /></txp:permlink>

<txp:excerpt />

…display articles in a different order?

To sort by title in ascending alphabetical order:

<txp:article sort="Title asc" />

To sort by Category 1 in descending order:

<txp:article sort="Category1 desc" />

To sort by Category 1 first, then article date:

<txp:article sort="Category1 asc, Posted asc" />

To sort by a custom field1:

<txp:article sort="custom_3 asc" />

…display “Top Stories” first, then regular articles?

Use a custom field to identify your top stories, and use this tag in your page template:

<txp:article sort="custom_5 asc" />

Storing numbers in custom field 5 will bring articles to the top, with higher numbers shown first.

1 You must use the custom_n name here, not the custom field name as defined in Advanced Preferences.

Diagnosing performance problems

Normally, Textpattern is one of the fastest CMS platforms around.

However, there are a few circumstances that can cause performance issues. If you’re experiencing slow page loading, here are some things to check:

Runtime vs. Display Time

Textpattern records the time it takes to generate and send each page. You can check the “runtime” figure to distinguish between slowdowns during page generation, and those that occur afterwards (i.e. during page rendering).

In admin > preferences, set Production Status to Testing. Load a Textpattern page, view the HTML source, and scroll to the bottom. You should see a comment block that looks something like this:

<!-- Runtime: 0.1316 -->
<!-- Queries: 21 -->
<!-- Memory: 1988Kb -->

The figures will vary according to your server, page templates, and so on. On a properly configured web server with a normal load and typical Textpattern templates and content, expected ranges are as follows:

  • Runtime: 0.01 – 0.5 seconds
  • Queries: 20 – 50
  • Memory: 1500 – 3000 Kb

Please note that these are approximate ranges – a Runtime of 0.6 or 0.7 is on the high side, but not necessarily cause for alarm if your page templates are complex. Also bear in mind that the figures will be different for each page load, and will vary due to external factors like the traffic load on your web server. Try loading the page several times over a period of a few minutes and compare the results. A one-off anomaly probably means a temporarily overloaded server or network.

If you’re experiencing consistently high numbers, here are some things to check.


A runtime figure that regularly measures 1 second or more usually indicates one of two things:

  • DNS issues. A slow or misconfigured DNS server at your web hosting company can cause high page runtimes. Usually this occurs in the Textpattern logging code. In textpattern > admin > preferences > advanced, set Use DNS to No, and see if that makes a difference. If not, try disabling logging altogether.
  • Plugins. Plugins aren’t necessarily as efficient as Textpattern itself. If your performance problems coincide with the installation of a plugin, or occur only on a particular page template that invokes a plugin, try disabling it and see if there’s a difference. If your page won’t display properly without the plugin, try temporarily reverting to the default Textpattern page template and form .
  • PHP code. If you’ve included any PHP code in your page templates, whether directly in the template or indirectly via an include() call or similar, try disabling it. In particular, check for any code that might try to fetch a file from an external server, e.g. by using a http://.. URL in an fopen() or include() call.
  • MySQL issues. MySQL doesn’t have to run on the same physical machine as your web server. Some hosting companies run these on separate servers connected by a fast LAN connection, which is fine. However, if Textpattern and MySQL are on entirely different networks, performance will be unaviodably slow, since all MySQL queries and results must travel back and forth over a comparatively slow internet connection every time a Textpattern page is viewed.

Other MySQL performance problems can be harder to diagnose. An overloaded MySQL server can slow down Textpattern – ask your hosting company if this could be the case.

Queries and Memory

A high number of queries, or excessive memory usage, is usually caused by a plugin or custom PHP code. As above, try disabling this code to see if it makes a difference. Plugins that produce a list of articles are the most likely culprits: some popular “archive” plugins are very inefficient, loading the entire database of articles into memory at once. For an efficient method of displaying an archive list of articles, see here.

Page rendering

If your Runtime, Queries and Memory figures are all in or near the normal limits, but you’re still experiencing slow page loading, the problem is almost certainly caused by the content of your page. Some things to check:

  • Javascript – does your page include javascript code? Try disabling it, it might be slow.
  • Counters and external stats – are you using an image or javascript link to an offsite “hit counter”, stats service, or a local stats application like Shortstat? Try removing the link to see if it makes a difference.
  • Links to off-site objects – does your page link to images, javascript, CSS or other objects on another web server? Do your pages include content from external sources such as Gravatars, del.icio.us or similar? Any of these could be the culprit.
  • Advertisements – banner, popup and text ads all work by loading content from another server. Try disabling them and measure the difference.
  • CSS – certain CSS techniques can cause choppy page loading and scrolling. In particular, “fixed” background images and blocks can cause loading and scrolling problems. These problems are all on the browser side, and are unrelated to Textpattern or the server.

Improving performance

There are a number of articles around about improving Textpattern’s performance. Not all of this is good advice – many are outdated, some disable important features for no measurable benefit, and a few suggested techniques can acutally result in worse performance.

If your Runtime/Queries/Memory figures are within normal limits, but you’d like to improve performance, here are the best methods to use:

  • Minimize plugins. The more plugins are active, the more code must be loaded, parsed and run. Don’t use a plugin when you can achieve the same results with a built-in tag. And make sure you disable any plugins you no longer use.
  • Simplify your code. Do your templates use complex nested conditionals, PHP code, or forms within forms? Simplify them. In particular, try to reduce the number of <txp:...> tags that require database queries. (If you’re not sure, remove tags one at a time and watch the Queries count).
  • Caching. Sometimes pages are necessarily complex, and there are limits to server performance. If you have a popular site that’s not fast enough, try a caching plugin such as asy_jpcache or zem_cache.

The important thing with any performance tweak is to change only one thing at a time, and always measure the results. If something has no real effect, change it back and try something else. You’ll almost certainly find that one or two changes will have a large effect, while others will be insignificant.

Help, I forgot my password!


How do I reset the administrator password?


A publisher can reset any user’s password. Provided there’s at least one publisher who can log in, ask them to reset your password for you.

If you’re the only user with publisher privileges (or the only Textpattern user at all), you’ll need to access the database directly to reset your password. Most web hosting accounts provide direct MySQL access using a program called phpMyAdmin, or via the command line. If you’re not sure how to access either of these, ask your hosting company’s tech support.

With phpMyAdmin, or at the MySQL command prompt, run the following query:

update txp_users set pass=password(lower('pass')) where name='user';

..where pass is the new password, and user is the login username.

Can I use Textpattern to do this?


Can I use Textpattern to build a web site like..


Textpattern is endlessly customizable and extendable via templates and plugins. It’s also open source, so you can modify the code as required. So the short answer to that question is: yes, you can build pretty much any kind of site you like with Textpattern, if you’re willing to do the work.

You’ll find many examples of Textpattern-powered sites listed in the Let’s See Yours, Then forum.

TXP Magazine’s txp sites gallery and sites collection by category list some well-designed web sites that use Textpattern.

If you break your requirements down into specific features and questions, you’ll find most of the answers in the Textbook documentation and this FAQ.

If what you really mean is, will someone please tell me how to do this, or can I just click a button and have my site look like this, or perhaps can I do this in the eight hours left before my deadline, we’ll leave you to work out the answers to those questions.