The Walden Effect: Farming, simple living, permaculture, and invention.

if

The if directive is supplied by the [[!iki plugins/conditional desc=conditional]] plugin.

With this directive, you can make text be conditionally displayed on a page. For example:

[[!if  test="enabled(smiley)"
      then="The smiley plugin is enabled :-)"
      else="No smiley plugin here.."]]

If the specified test succeeds, the then text will be displayed, otherwise the else text will be displayed. The else part is optional.

The then and else values can include any markup that would be allowed in the wiki page outside the template. Triple-quoting the values even allows quotes to be included.

The test is a PageSpec; if it matches any page in the wiki then it succeeds. So you can do things like testing for the existence of a page or pages, testing to see if any pages were created in a given month, and so on.

If you want the PageSpec to only match against the page that contains the conditional, rather than matching against all pages in the wiki, set the "all" parameter to "no".

In an if directive, the regular PageSpec syntax is expanded with the following additional tests:



Anna Hess's books
Want more in-depth information? Browse through our books.

Or explore more posts by date or by subject.

About us: Anna Hess and Mark Hamilton spent over a decade living self-sufficiently in the mountains of Virginia before moving north to start over from scratch in the foothills of Ohio. They've experimented with permaculture, no-till gardening, trailersteading, home-based microbusinesses and much more, writing about their adventures in both blogs and books.



Want to be notified when new comments are posted on this page? Click on the RSS button after you add a comment to subscribe to the comment feed, or simply check the box beside "email replies to me" while writing your comment.






profile counter myspace



Powered by Branchable Wiki Hosting.

Required disclosures:

As an Amazon Associate, I earn a few pennies every time you buy something using one of my affiliate links. Don't worry, though --- I only recommend products I thoroughly stand behind!

Also, this site has Google ads on it. Third party vendors, including Google, use cookies to serve ads based on a user's prior visits to a website. Google's use of advertising cookies enables it and its partners to serve ads to users based on their visit to various sites. You can opt out of personalized advertising by visiting this site.