On Sun, Oct 11, 2015 at 10:35 AM, Declan McCabe <
declan...@gmail.com> wrote:
> So, I edited the two fields here:
>
http://wikieducator.org/Template:InsectSection
>
> My question: is there an efficient way to push the new blank fields out to
> all of the existing templates? Or should I plan on editing them one at a
> time....which is fine if that's the way it needs to be done. The fields
> need to be optional....because not all bugs have common names or tied flies.
I think there are a few options (but I'm not certain I've understood
the real question, so it might be best to chat a bit on IRC,
CollabOERate, or Google Hangouts to explore a bit).
1. The Mediawiki template language is quite ugly to "program" but it
does have the ability to deal with unspecified parameters.
{{foo|altstring}} will return the value of the foo parameter if it has
been defined, or the wikitext altstring if it hasn't. And the
altstring can be empty, so {{foo|}} is a construct you see a lot when
you just want to ignore unspecified parameters.
2. There are a number of parser functions that allow you to wrap
conditionals around sections of wikitext, and #if and #ifeq come in
really handy when dealing with optional parameters.
https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23if
So given that, you could just edit the downstream (pardon the pun)
insect templates that actually have common names... and the presence
of the parameters would trigger conditional rendering in the parent
Template:InsectSection. That is probably the "right" way of attacking
the problem.
I was tempted to prototype this for you by adding the common name (and
tied fly name) to the Template:OrderFamilyGenus so they would all
render in that same column... but it is probably best to wait to (a)
see if I've actually understood the problem and (b) find out how you
were planning to render the new fields in the output.
But there is another way that would be quick-and-dirty but probably
not scale well in the long term. You could put a #switch parser
function in Template:InsectSection that would derive the common name
based on the genus/species of the child templates. This would work
great for existing templates, but would require touching two places as
new insects were added (unless you combined it with the conditional
method mentioned in 2. above).
https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#.23switch
Example of something similar:
http://wikieducator.org/Template:IDevice/line
> I'm revisiting this because we have a new team of programmers redesigning
> our Iphone app.
Cool to see work continuing on the Streams project.
Jim