#How to code a template to add many group fields inside a template

18 messages · Page 1 of 1 (latest)

midnight hull
#

It's very difficult for me to explain, but attaching these two pictures will help better. How do I code in a way I just add a digit number after the parameter's name in order to add a new info in a row without adding extra codes in the template, because would be more unnecessary large.

north lintel
#

Like a dynamic Template with a Plus X raw if said condition ? No idea but if I can make your request clearer then it's already something

midnight hull
#

...

north lintel
#

Sorry tried 😅

midnight hull
north lintel
#

Kinda, found a way but don't know if you will like it, testing on my side first. I had a expression at first but it was creating a loop.

north lintel
#

Oh wait, looking at it now it looks like yours but yours is better since you don't have the amount input 🤔

midnight hull
#

(Where is canada when you need it?)

north lintel
#

Too far i'm afraid XD

upbeat jasper
#

So you want a variable amount of parameters in your template?

north lintel
#

I thought I had an idea but it didn't work, so I admit it's beyond my capabilities. Sorry really wished I could have helped.

still mountain
#

Alternatively you could write a Lua module with Scribunto that loops through the arguments

midnight hull
upbeat jasper
#

Yeah, there really is not any easy and nice way to do that with pure wikitext, I don't think. You are probably gonna have to look at Lua for that. I don't really know much about the specifics of Lua though, to really give you an example

still mountain
# midnight hull How could I implement that?

According to the docs, something like this should work (untested):

{{#forargs: title
 | key
 | value
 | Title: {{#var: value }}
Description: {{{description{{#var: key }}}}}
}}

This shows the title and description for each title + description you enter, ofc you have to replace that text with the actual template/content you want to display for each entry