Conditional Blocks (For use in included pages)


This section on the Community is no longer supported, in favour of Wikidot's Official Feedback Site.

It is retained here for archiving purposes.

Wish List


Template "template:wishlist" can not be found.

Tags

Posted by mattdmmattdm on 12 Sep 2008 16:33, last edited on 27 Mar 2009 23:09

This wish is open

Description

Summary:

[[if {$var}==string]] Then show this block. [[/if]]

Details:

The power of included pages (or templates, for that matter) would be significantly enhanced if certain portions of the page could be included or not depending on the value of a variable. Like this:

[[if {$var}==string]]
Then show this block.
[[/if]]

Possibly with an "else" block as well, although having != as a possibility could accomplish the same thing.

And in fact, a more minimal version which doesn't require any comparisons:

[[ifdef {$var}]]
Then show this block.
[[/ifdef]]

would be useful in many of the situations I'm envisioning.

Partial work around:

1. iftags conditions work now!

have a look to use iftags: http://community.wikidot.com/glossary:tags

2. "Include" technic

Erich Steinboeck has developed several clever ways to get this functionality:

Basically, this works by exploiting quirks in the way comments are processed.

However, the increased complexity is a huge downside. It's a solution for Wikidot experts. And it unfortunately pushes some of that complexity to the including page, which means that it's not ideal even the case where an expert creates a template for general users.

Additionally, the way these tricks rely on particular parsing behaviour makes them fragile.

Links to forum Posts

Conditional blocks for use in included pages
Separation of data and display
Hide text in included page


Rate this Wish

We encourage you to "rate" the suggestions. The higher the rating, the better the chance of the wish being granted (well, possibly).

rating: +20+x
Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.