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
Tags
Posted by mattdm 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).
But what if you could then allow a user enter the variable in a text box. Could lead to some interesting results. (Takes me back to my C++ days)
I need something like this for a wiki I want to develop!
This page is now rather old. The official place to request features is at http://feedback.wikidot.com. I can't see a wish drectly related to this (http://feedback.wikidot.com/system:page-tags/tag/conditional/category/wish) so you might want to create one.
Rob Elliott - Strathpeffer, Scotland - Wikidot first line support & community admin team.
And I've also written a snippet include code that kind of works around this: http://cond.wikidot.com/
[[include :cond:if START |unique=1|type=equal|var1=%%form_data{agree}%%|var2=iagree]]
You have agreed to the Terms and Conditions of the site.
[[include :cond:if END]]
Kenneth Tsang (@jxeeno)