Forum:Template Coding Help: If A exists, go A. Otherwise B.

Hello. I'm currently helping a wiki site at http://evchk.wikia.com/ (a Chinese wiki).

I have only shallow knowledge about wiki template coding. I have a question regarding a template Zhwiki.

This is what I want to achieve:

Plan A:
 * If our wiki (that is http://evchk.wikia.com/ ) has an article on this item, link to it: |}}
 * Otherwise, link to the famous Chinese Wikipedia's if it has an article on it:
 * Otherwise, just create a non-existing link of the item pointing to our wiki: |}}

UPDATED (Since someone says Plan A is mission impossible, what about Plan B?)

Plan B:
 * If our wiki (that is http://evchk.wikia.com/ ) has an article on this item, link to it: |}}
 * Otherwise, link to the famous Chinese Wikipedia's:

You can also specify the name of the intra-link:
 * Put and you get IP address.
 * Put and you get IP (linking to IP address).

By the way, are there any tools/ways available to preview the effect of the template first before putting in real use? I'm usually afraid I made a mistake in template coding and mess this template up. Also is there any dummy guide available to learn wiki template coding? --Comeon 12:07, 11 February 2009 (UTC)


 * Not possible that I know of, unfortunately. The 2nd step is the deal breaker, since we have no way to know what is or is not on Wikipedia. --Sky (talk) 14:36, 11 February 2009 (UTC)


 * What if I slightly changed the content, that is, Plan B (see above)? Something is better than nothing. --Comeon 23:25, 11 February 2009 (UTC)


 * The second is easily doable, but requires an expensive parser call (see more), which means it can only be included so many times on a page before the page breaks. Plan A would also have required this step. The coding would be:

{{#ifexist:{{{1|}}}
 * |
 * {{{2|{{{1}}}}}}

That said, wouldn't it be better if your wiki filled out instead; i.e., red links to be filled?... As for dummy guide, not really. There is a help wikia, as well as mediawiki.org for most documentation. --Sky (talk) 00:03, 12 February 2009 (UTC)


 * Sorry for the very late reply. I have edited the above code to fix minor bugs. I have one idea to partly relieve the server burder.

{{#ifexist:{{{1|}}}
 * Output (Subst) the result of "{{{2|{{{1}}}}}}"
 * {{{2|{{{1}}}}}}

Note: No more than 100 (inclusive) expensive parser call.

What code should I put so the code will be SUBST-ed (i.e. automatic conversion of wikitexts) if the first condition is matched, in other words, no further "ifexist" call will be made.

PS: Some people say they hate to see red links. That's why such workaround. --Comeon 06:40, 22 March 2009 (UTC)