Template talk:RQ:Twain What Is Man

From Wiktionary, the free dictionary
Jump to navigation Jump to search

@Sgconlaw: when the module sees a value in the first positional parameter, it tries to use it as the language code for the quote, as it would with the {{quote}} template. I suspect it has something to do with "1" being in the list given to |propagateparams=. Perhaps you need to take "1" out of that list and just make sure that your template code passes |1= to |page= There is currently a module error at Wiktionary:Quotations/Templates/English T–Z due to this. I checked a transcludes in an entry, and was able to get an error in preview by changing |page= to |1=. Chuck Entz (talk) 23:54, 9 February 2024 (UTC)[reply]

@Chuck Entz: OK. Since all quotations have been updated to use “Module:quote”, I’m struggling a little to figure out how |propagateparams= and |allowparams= work as I’m unsure what parameters need to be explicitly specified under each one. I’ll need to ask @JeffDoozan for help here. Specifically, if I wish to designate |1= as a synonym for |page= and other numbered parameters, where do I specify them? Does the order of the parameters listed under |propagateparams= and |allowparams= matter? — Sgconlaw (talk) 04:55, 10 February 2024 (UTC)[reply]
@Sgconlaw: my understanding is that |propagateparams= basically tells the module to take the listed parameters as its own, while |allowparams= basically tells the module not to throw an error if any parameter on the list is present but not in the module's list of permissible parameters. That means you would want to include every parameter possible in |allowparams=, but be selective with |propagateparams=. I suspect what you want to do here is leave |1= out of |propagateparams=, and assign |1= to |page= if |1= is present. I'm a little fuzzy about whether you would need to include |page= in |propagateparams=, but I believe you would. Perhaps @Benwing2 can explain, since he wrote the code. Chuck Entz (talk) 06:30, 10 February 2024 (UTC)[reply]
@Sgconlaw: Chuck did a great job of explaining the why and how of both two paramaters, so I'll just add some guidelines and examples.
Instead of writing, |foo = {{foo|}}, you can add "foo" to |propagateparams=.[1] That's it - nothing else should ever go in |propagateparams=. If you prefer writing the full line, you can keep doing so and never use |propagateparams=.
|allowparams= is important because it tells the module when it should warn the user that they've made a typo, used the wrong paramater name, or are trying to add data the template is just going to ignore. If you've written {{{bar}}} or {{{bar| anywhere in the template, add "bar" to |allowparams=.
I learn well from examples, so here are some illustrative diffs from the bot conversion: diff - using propagateparams= instead of individual lines, diff - using allowparams, diff using pageparam= and textparam=, diff using everything, diff (lots of variables used inside the template that need to be added to allowparams=), diff (lots of lines simplified to "propagatedparams").
  1. ^ To save you having to add propagateparams= to every single template, the very most common params: "passage", "text", "brackets" and "footer" are always included automatically and you never have to manually add them to propagateparams. Likewise, if you use |pageparam= then "page", "pages" and the synonyms you listed in pageparam will also be automatically included, and don't need to be manually listed in propagateparams.
  2. JeffDoozan (talk) 14:17, 10 February 2024 (UTC)[reply]
    @Chuck Entz, JeffDoozan: thank you both for your explanations and patience. I have been trying to get to grips with the parameters, although I am still struggling a little bit. For example, did I set up {{RQ:Spenser Fowre Hymnes}} properly? — Sgconlaw (talk) 22:28, 14 February 2024 (UTC)[reply]
    @Sgconlaw: Good work, {{RQ:Spenser Fowre Hymnes}} is perfect! It looks like you've got the hang of it! JeffDoozan (talk) 00:23, 15 February 2024 (UTC)[reply]

    ──────────────────────────────────────────────────────────────────────────────────────────────────── @JeffDoozan unfortunately not. In {{RQ:Young Centaur}} I can't get the chapter name to display when the page number is specified, even when I have put "1" in |allowparams=. What's wrong? Also, if I have used |pageparam= and |textparam=, do I still need to put "1" and "2" in |allowparams=?

    Sgconlaw (talk) 16:35, 15 February 2024 (UTC)[reply]

    @Sgconlaw: I think the chapter display problem is buried somewhere in the if-switch logic. Switching it to |chapter = The chapter containing page {{{page|}}} displays as expected. For development and debugging, you can build the templates exactly as you've always done, with |allowparams=* and, when everything works, figure out what should go in |propagateparams= and |allowparams=. With {{RQ:Young Centaur}}, you shouldn't include chapter to |allowparams= because you're generating the |chapter= inside the template so anything a user passes to |chapter= will just be ignored.
    {{RQ:Young Centaur|chapter=THIS TEXT WILL NEVER BE DISPLAYED|page=256}}
    JeffDoozan (talk) 17:28, 15 February 2024 (UTC)[reply]
    @JeffDoozan: ah, you were right! A question: if, for example, |pageparam=1 and |textparam=2 have already been set, do I still need to include |allowparams=1,2? — Sgconlaw (talk) 19:45, 15 February 2024 (UTC)[reply]
    @Sgconlaw: Sorry for not answering your question in my earlier reply. No, any parameter listed in |pageparam= or |textparam= does not need to included manually in |allowparams= because by listing a parameter in either of those lists, you're already telling the module that it's an allowed parameter.
    In case you're interested in the technical reason that |allowparams= exists: everything inside of double {{...}} or triple braces {{{...}}} is resolved to text before the module code is run, so |chapter = {{#ifexpr:{{{page|}}}{{{pageref|}}}{{{1|}}}<100|First Chapter|Second Chapter}} simply becomes |chapter=First Chapter. This means that athough the module will see all of the parameters provided, it has no way of knowing if {{{page}}} or {{{pageref}}} was part of the template code, or if they are parameters that were accidentally included by the user. Setting |allowparams= is the way to tell the module that those parameters exist for a reason and that it shouldn't generate an error when it sees them. JeffDoozan (talk) 20:24, 15 February 2024 (UTC)[reply]