Hide or comment out content

Here is a very simple tip for hiding text, tags or other content while actively working on a site.

While working on new sites or design iterations one needs from time to time to remove content, leave a comment or suppress a tag or output. The normal method is simply to remove the content, but this can end up with working against you if you can’t remember later what you deleted, or you don’t have a backup (can’t tell you how many times I made this mistake in the past!).

The txp:hide tag

This little used Textpattern tag can help you a lot in many situations:

  1. When working with a team on a site and you need to leave comments in the code
  2. When you need to hide or suppress a portion of text or code in the page template
  3. When you want to test different code without removing the original code

An example

The txp:hide tag instructs TXP to hide whatever is wrapped inside the tag itself, like so:

<txp:hide>
Try another side menu, this one does not set an active class...
<ol class="work-list">
<txp:article_custom section="work" limit="20" class="active">
<li><txp:permlink><txp:title /></txp:permlink></li>
</txp:article>
</ol>
</txp:hide>

Lets try this one instead!

<ol class="work-list">
<txp:article_custom section="work" limit="20" class="active">
<li <txp:if_article_id> class="active"</txp:if_article_id>><txp:permlink><txp:title /></txp:permlink></li>
</txp:article>
</ol>

Although a simple tip, it can be very productive in your workflow.

comments powered by Disqus