Pseudo TXP if_not

There are a myriad of plugins out there for Textpattern, and I get quite a few emails asking if I know of ones that add negative conditionals. Being the perfectionist that I am though, I tend to shy away from plugins unless there is simply no other solution to the problem. This is for two reasons: First, I don't like having to keep track of all of the plugins I am using, and the URLs for each one. Secondly, sometimes developers cease work on their projects, and Textpattern upgrades cause these older plugins to be broken.

I figured this out awhile ago on my own, and then kicked myself when I saw it already covered in the Textpattern FAQ. Yet, I think it bears repeating here. I give to you the super-duper no brainer pseudo method for creating negative conditionals. Let's say, for example you want to do something only if you are not on a certain section, named "example." That would look like this…

<txp:if_section name="example"><txp:else />
Do something here.

See what's going on there? Rather than place something between the opening txp:if_section and the txp:else, there is nothing. So, if it is that section, no content will be displayed or action taken. However, if it is not the section named "example," then your specified content will be displayed. Now, in some programming languages, this would throw an error. In Textpattern though, you're golden. This works with a variety of TXP tags, such as categories. Hopefully this will help, and save you time searching for specific plugins.