Template talk:Yearpage

From Greyhawk Wiki
Jump to navigation Jump to search

Detecting references

Hey, Rexidos ... totally random thought ... in cases like this one, or on the "Third century CY, where it pulls from the timeline in particular ways ... Is there a Mediwiki method that the template can detect the text of it is pulling?

Like, I guess what I'm asking is whether we can make the template detect if there's <ref>s or {{csb}s or {{refn}}s in the text it's pulling?

I guess what I'm asking is would it be possible to use {{YearPage}} to detect {{csb}} and then make it look like citations are different by show or don't show certain code? Like in a way, toggle on or off a feature like "inline" or "short"?

Like, if a reference were detected, then display === Notes === that doesn't otherwise display? Or if a reference were detected, can it set something for the page, like make it substitute "inline=yes" to "inline=no" just for the specific page it appears on. Or just have it show or not show anything that would appear under ? Do you know if there's a "<no references />" or something like that?—--Abra Saghast (talk) 12:24, 4 September 2025 (EDT)

There is a Mediawiki function for checking if text contains a certain string, but it only works on short strings under 1,000 bytes, so it doesn't work for this use case (I tested it).
If I understand correctly, you're talking about at least three separate problems:
  • Toggling {{csb}} "inline" mode depending on what page it's on. You might do this in the csb template by detecting whether {{PAGENAME}} is equal to "World of Greyhawk Timeline". You might also use <noinclude> or <includeonly> tags to create sections which only appear in the Timeline, but not when included in individual pages, or vice-versa.
    • Perhaps it would be more elegant to have a second template for this purpose; e.g. {{book|Living Greyhawk Gazetteer|40}} might produce "Living Greyhawk Gazetteer (2000), p.40", and {{book|Living Greyhawk Gazetteer|40}} would produce the same but enclosed in the appropriate <ref> tags.
    • However, assuming that only the Timeline needs the inline tags, I think it would be a more elegant solution for the timeline to simply use no template at all. It's surely simplest to say e.g. "(The Star Cairns p.40; Dragon #241 p.20)", or if necessary, to apply wikilinks and italics too, e.g. "(The Star Cairns p.40; Dragon #241 p.20)". The only benefits of the {{csb}} template beyond this are footnote collation (not used inline), a comma after the book title (omitted inline for brevity), book publication year (unnecessarily verbose), and recognizing abbreviations to save editor effort (unnecessary as the Timeline almost never needs updated).
  • Hiding the heading for reference sections which would be empty (e.g. hiding the Notes heading on pages with no notes). I don't know how this would be done. Most wikis seem to just assume an editor will manually insert the Notes heading on pages where there are notes.
  • Hiding references on some pages. I don't believe this can be done. I tried enclosing the <references /> tag in <-- HTML comment tags --->, but references automatically appear at the bottom of any page missing its references tag. Rexidos (talk) 12:11, 5 September 2025 (EDT)