Using the `hide` tag in Textpattern CMS


The Textpattern CMS `hide` tag is a simple yet highly useful tag, as the name implies, it hides everything inside its container from appearing in markup. Like this:

<txp:hide>This is hidden. It won't make it to the browser.</txp:hide>

I can’t show you what it looks like in the browser because nothing appears. At all. Hence the name `hide`. Clever, huh? It’s incredibly handy for comments, notes, identifying text and all sorts of other things. That said, it’s a different beast to the HTML commenting out syntax that you may already be familiar with.

Take this example:

<txp:hide>This is hidden. It won't make it to the browser.</txp:hide>
<!-- This is commented out, but will appear in the browser -->

When that is rendered to the browser, the first line will not appear, while the commented out line will. The upshot of this is that nosey site readers will be able to view source and see the comments inside the HTML comments part, but the stuff inside Textpatterns `hide` syntax will be for those who can view the Textpattern admin-side only. Perhaps you’re making a to-do note or advising a fellow developer of an inelegant kludge you made to get something working just right – regardless of your reasons, stuff that’s hidden with `hide` stays hidden on the front end.

Personally, I use `hide` extensively for identifying chunks of code. I have many Textpattern sites, each with a whole raft of pages, styles, forms and other blocks of text. At the start and end of each file, I have this block of code:

Name: default & error_default
Type: page
Date: June 2015
Info: Same template - default and error page

That’s an 80-character wide top-and-tail block so I can easily see what I’m copying and pasting into Textpattern. It took a bit of time to fine-tune, and there’s extra work for Textpattern to process (hide) the innards, but the benefits outweigh the ever-so-slightly increased load time and query count. When there’s a lot of iterative work going on in my development (i.e., change something, save the file, copy the text, paste the the text into the browser window, save it, flip to the front end tab to see what it looks like, rinse and repeat), it’s especially important to have these visual confirmations that the right thing is going to the right place. Textpattern storing almost everything in the database is both a blessing and curse in equal measure.

Next time: you’ll learn about the ins and outs of comment-tags.

Thanks for reading.

Looking for quality Textpattern Hosting? Look no further than Arvixe Web Hosting and use coupon TEXTPATTERN for 20% off your first invoice!

Tags: , , , , , , , , , , , , | Posted under Textpattern | RSS 2.0

Author Spotlight

Pete Cooper

Pete Cooper has been using Textpattern since 2005. Textpattern is his preferred CMS weapon of choice. Its logical and flexible approach to content management makes Pete happy, as does its lightweight core and helpful user community. Pete's website - - runs on top of Textpattern and chronicles his day-to-day experiences from his home near the Atlantic in north Cornwall, United Kingdom.

Leave a Reply

Your email address will not be published. Required fields are marked *