Help talk:Template: Difference between revisions
Line 224: | Line 224: | ||
I make regular edits to a page on Wikipedia, which includes a table, and a count of the number of rows in that table. It is common for someone to add/remove a row in the table without updating the manual count. I've developed a template that keeps a count of how often it is transcluded on the page, but I wanted to know if one already existed. What would be a good name for it ("count" is already in use)? -- [[User:Jevanyn|Jevanyn]] <sub>[[User talk:Jevanyn|talk]]</sub> 20:05, 15 April 2015 (UTC) |
I make regular edits to a page on Wikipedia, which includes a table, and a count of the number of rows in that table. It is common for someone to add/remove a row in the table without updating the manual count. I've developed a template that keeps a count of how often it is transcluded on the page, but I wanted to know if one already existed. What would be a good name for it ("count" is already in use)? -- [[User:Jevanyn|Jevanyn]] <sub>[[User talk:Jevanyn|talk]]</sub> 20:05, 15 April 2015 (UTC) |
||
:[[User:Jevanyn|Jevanyn]], where is the template? [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 13:41, 25 April 2015 (UTC) |
:[[User:Jevanyn|Jevanyn]], where is the template? [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 13:41, 25 April 2015 (UTC) |
||
::On another wiki. The main use case is on Wikipedia, though, on the [[List of oldest living people]]. There is a table of names that many users add/remove records in, but the text specifies how many men and women are listed, which frequently gets out of sync. I wanted to replace the "F" and "M" with ((count|F)) and ((count|M)), and put the counted totals in the text after the table. My question here was primarily what to call the templates so that they can be easily found and reused. -- [[User:Jevanyn|Jevanyn]] <sub>[[User talk:Jevanyn|talk]]</sub> 20:36, 27 April 2015 (UTC) |
Revision as of 20:36, 27 April 2015
![]() | Wikipedia Help C‑class High‑importance | |||||||||
|
![]() | Templates | |||
|
![]() | Help:Template has an associated feedback page, Help:Template/feedback. It should be checked regularly, and posts responded to or deleted as appropriate. |
|
|||||
This page has archives. Sections older than 90 days may be automatically archived by Lowercase sigmabot III when more than 10 sections are present. |
Problem with if scripts
I'm a user on the Danish version of Uncyclopedia ([1]). I've been trying to get this template to work in a few days, but somehow it just won't do as I want. It's meant to create a table with two rows and a picture to the right. In the upper row, there is going to be security marks for a product, while the lower row is going to have up to four columns with product descriptions.
The problem lies in the upper row, as the lower row already works. Se the result here: [2]
Here's the script (most of it is in English; only security mark descriptions are in Danish). You should look at the script of this page, as Wiki puts everything into one line here:
{| border="1" class="metadata" style="width:100%; background-color:rgb(255,102,0)" | {{ #ifeq: {{{picton|0}}} | 0 | colspan="2" | }} style="align:center;" | {{ #if: {{{1mark|}}} | {| | [[billede:{{ #switch: {{{1mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{1mark|}}}.gif | #default = {{{1mark|}}} }}]] |- ! <big>{{{1head|}}}</big> |- | {{{1text|}}} |} | }} {{ #if: {{{2mark}}} | {| | [[billede:{{ #switch: {{{2mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{2mark|}}}.gif | #default = {{{2mark|}}} }}]] |- ! <big>{{{2head|}}}</big> |- | {{{2text|}}} |} | }} {{ #if: {{{3mark}}} | {| | [[billede:{{ #switch: {{{3mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{3mark|}}}.gif | #default = {{{3mark|}}} }}]] |- ! <big>{{{3head|}}}</big> |- | {{{3text|}}} |} | }} {{ #if: {{{4mark}}} | {| | [[billede:{{ #switch: {{{4mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{4mark|}}}.gif | #default = {{{4mark|}}} }}]] |- ! <big>{{{4head|}}}</big> |- | {{{4text|}}} |} | }} {{ #if: {{{5mark}}} | {| | [[billede:{{ #switch: {{{5mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{5mark|}}}.gif | #default = {{{5mark|}}} }}]] |- ! <big>{{{5head|}}}</big> |- | {{{5text|}}} |} | }} {{ #if: {{{6mark}}} | {| | [[billede:{{ #switch: {{{6mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{6mark|}}}.gif | #default = {{{6mark|}}} }}]] |- ! <big>{{{6head|}}}</big> |- | {{{6text|}}} |} | }} {{ #if: {{{7mark}}} | {| | [[billede:{{ #switch: {{{7mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{7mark|}}}.gif | #default = {{{7mark|}}} }}]] |- ! <big>{{{7head|}}}</big> |- | {{{7text|}}} |} | }} {{ #if: {{{8mark}}} | {| | [[billede:{{ #switch: {{{8mark|}}} | ætsende | miljøfarlig | lokalirriterende | giftig | eksplosiv | brandnærende | brandfarlig = {{{8mark|}}}.gif | #default = {{{8mark|}}} }}]] |- ! <big>{{{8head|}}}</big> |- | {{{8text|}}} |}|}} | {{ #ifeq: {{{picton|0}}} | 1 | rowspan="2" width="{{{pictwidth|}}}" }} | {{ #ifeq: {{{picton|0}}} | 1 | [[billede:{{{pictaddr|}}}|{{{pictwidth|}}}]] }} |- | {{ #ifeq: {{{picton|0}}} | 0 | colspan="2" }} | {{ #ifexpr: {{{cols|1}}} >= 1 |<div style="width: {{ #expr: 100 /{{{cols|1}}} }}%; float: left;">{{{1col|}}}</div>}} {{ #ifexpr: {{{cols|1}}} >= 2 |<div style="width: {{ #expr: 100 /{{{cols|1}}} }}%; float: left;">{{{2col|}}}</div>}} {{ #ifexpr: {{{cols|1}}} >= 3 |<div style="width: {{ #expr: 100 /{{{cols|1}}} }}%; float: left;">{{{3col|}}}</div>}} {{ #ifexpr: {{{cols|1}}} >= 4 |<div style="width: {{ #expr: 100 /{{{cols|1}}} }}%; float: left;">{{{4col|}}}</div>}} |} — Preceding unsigned comment added by 90.185.27.224 (talk) 18:00, 16 November 2008
Template naming conventions
I've suggested standardizing template naming, at Wikipedia talk:Template namespace#Template naming conventions. If you're frustrated with typing template names and constantly guessing at the right capitalization and spacing, please chime in. —Michael Z. 2009-01-10 17:46 z
Template that can detect being inside of an archived discussion
Is there a method for a template to detect whether it's inside a discussion that has been archived? Say a template within a discussion that would change when between {{Archive top}} and its bottom? Couldn't find anything in search czar ♔ 04:56, 24 May 2014 (UTC)
- Technically, yes: but not solely with a template, we'd need to add something to the site CSS as well. What I'm thinking is that we define a new class - say
changeifarchived
- which behaves differently according to whether it's enclosed by{{archive top}}
or not; it would make use of any class that is used by{{archive top}}
. At present,{{archive top}}
wraps the thread in<div class="boilerplate">
so we could make use of that; the downside is that theboilerplate
class is used in other places for non-archival purposes. It might be best to also add a second class to{{archive top}}
, sayclass="boilerplate archivedthread"
, and then we can set up the CSS rulesThen we make sure that our template wraps its content in the new.changeifarchived { border: 1px solid blue; } div.archivedthread .changeifarchived { border: 3px dotted red; }
changeifarchived
class - it doesn't matter if it uses<div>...</div>
<span>...</span>
or another element. Let's assume that we have a template called{{different if archived}}
coded asand we use it like this<span class="changeifarchived">{{{1}}}</span>
The effect would be like this:{{archive top}} Some archived text {{different if archived|with a template}} inside it. {{archive bottom}} :Some non-archived text {{different if archived|with a template}} inside it.
The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
Some archived text with a template inside it.
- Some non-archived text with a template inside it.
- This isn't a working demonstration - I didn't set up any classes or templates. The border patterns are just examples. --Redrose64 (talk) 10:32, 24 May 2014 (UTC)
- @Redrose64, would this require that the CSS rules be set in advance? It would be preferable to be able to style the change within the template (because a dotted border may not be the intended change across templates). It there any way to do this now with a template detecting that it's within a "boilerplate" class without going back to the sitewide CSS rules? czar ♔ 14:10, 24 May 2014 (UTC)
- Unless I'm completely misunderstanding the request, this can most certainly be done with just templateFu. I'll take a better look in about 10 hours from my computer when I get home. — {{U|Technical 13}} (t • e • c) 14:33, 24 May 2014 (UTC)
- @Czar: There are two ways of applying styling. One is by placing inline styling into the
style=""
attribute of an HTML element, as in- these cannot be applied conditionally, and so there is no way for the border to be automatically coloured differently according to what surrounds that<span style="border: 3px dotted red;">some styled text</span>
<span>...</span>
element. The other way is by using style sheets - the CSS files - which are applied to the element by various means known as selectors. Selectors can get complicated, but they can pinpoint particular elements on a page according to criteria like "if an element of type x is inside another element of type y, style it this way, otherwise style it that way". Class selectors are perhaps the easiest to understand - in my first boxed example above, the first line begins.changeifarchived
- this means "any element that has thechangeifarchived
class should be styled this way". The fourth line beginsdiv.archivedthread .changeifarchived
- this means "any element that has thechangeifarchived
class, and which is also enclosed by a<div>...</div>
element that has thearchivedthread
class, should be styled this way"; it uses the descendant combinator to specify this. - When you write templates that style the text, they can use either the style method or the class method; but to utilise the class method, the classes concerned need to be defined in a CSS file. Since we can't set these up on a per-page or per-template basis, they would need to go into the site CSS. See for example the request at MediaWiki talk:Common.css#Glossary classes. --Redrose64 (talk) 14:38, 24 May 2014 (UTC)
- Thanks for the write-up. I'm already familiar with how CSS works. I wanted to use this not to style a section differently when inside a boilerplate/changedifarchived class (though that can be useful for other reasons), but to automatically remove a category (as added through a template) when the section has been archived. czar ♔ 15:02, 24 May 2014 (UTC)
- I'm pretty sure that it's not possible, since open WP:AFD debates have a
{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD}}
, the sole purpose of which is to add two categories (like Category:AfD debates (Not yet sorted) and Category:AfD debates) which needs to be manually removed when the AFD is closed. --Redrose64 (talk) 15:10, 24 May 2014 (UTC)- Okay. Part of me asking was to see whether that could be helped (and, you know, it would be useful for other reasons) czar ♔ 15:13, 24 May 2014 (UTC)
- I'm pretty sure that it's not possible, since open WP:AFD debates have a
- Thanks for the write-up. I'm already familiar with how CSS works. I wanted to use this not to style a section differently when inside a boilerplate/changedifarchived class (though that can be useful for other reasons), but to automatically remove a category (as added through a template) when the section has been archived. czar ♔ 15:02, 24 May 2014 (UTC)
- @Redrose64, would this require that the CSS rules be set in advance? It would be preferable to be able to style the change within the template (because a dotted border may not be the intended change across templates). It there any way to do this now with a template detecting that it's within a "boilerplate" class without going back to the sitewide CSS rules? czar ♔ 14:10, 24 May 2014 (UTC)
- From what I can read on my phone, what you want is possible inside of a template although it is not instantaneous as it requires waiting for the job queue to keep it updated and sometimes requires a null edit of which there are bots for. — {{U|Technical 13}} (t • e • c) 15:30, 24 May 2014 (UTC)
- @Technical 13, I'd be interested in reading more about this if you can send me a link when you get to a computer. Thanks for your help, all czar ♔ 15:39, 24 May 2014 (UTC)
- Ahh.. okay, now I can read it better. When you say archived, you just mean closed to future discussion, and not actually archived on the archive page. I do believe that can be done with Lua, it can also be done with css as Rose suggests in cooperation of a template, or it could be done via JavaScript. "If" you had meant what I thought you did of it actually being archived on an archive page, then the template could read the pagename, check to see if "archive" was included in the title, and style or change the categories with parser functions. — {{U|Technical 13}} (t • e • c) 21:47, 24 May 2014 (UTC)
- @Technical 13, I'd be interested in reading more about this if you can send me a link when you get to a computer. Thanks for your help, all czar ♔ 15:39, 24 May 2014 (UTC)
Lang-eu
There seems to be a display problem specific to the Basque-language version of {{Lang}}. At Asno de las Encartaciones I wanted the opening of the lead sentence to read "The Asno de las Encartaciones, Basque: Enkarterriko asto, is ..." (which of course I could do by writing it in that way, without using the template at all). But using {{lang-eu}} produces this result: "The Asno de las Encartaciones', Basque: Enkarterriko asto', is ...". Changing the language to, say, Spanish, (i.e., changing the letter u of eu to an s without making any other change) causes it to display as expected. Can anyone see what the problem might be (most likely is user error, of course); or even fix it? Thanks, Justlettersandnumbers (talk) 11:23, 9 July 2014 (UTC)
- @Justlettersandnumbers: My second attempt seems to have worked, but I have no idea why {{lang-eu}} and {{lang-es}} behave differently. -- John of Reading (talk) 12:19, 9 July 2014 (UTC)
- Yes, your fix is good (I thought I'd tried that, but obviously not); but it doesn't solve the underlying problem, which as far as I know is limited to this one variety of {{Lang}} (of course, I haven't actually gone through the other 200? 300? to check), and I think needs looking at. Justlettersandnumbers (talk) 13:33, 9 July 2014 (UTC)
- This edit is the proper fix. --Redrose64 (talk) 15:23, 9 July 2014 (UTC)
- Ha! Obvious once it's been pointed out. -- John of Reading (talk) 16:29, 9 July 2014 (UTC)
- This edit is the proper fix. --Redrose64 (talk) 15:23, 9 July 2014 (UTC)
- Yes, your fix is good (I thought I'd tried that, but obviously not); but it doesn't solve the underlying problem, which as far as I know is limited to this one variety of {{Lang}} (of course, I haven't actually gone through the other 200? 300? to check), and I think needs looking at. Justlettersandnumbers (talk) 13:33, 9 July 2014 (UTC)
How to variablize Category url
I'm having trouble creating a link to a Category page utilizing a variable string passed as a parameter: [[Category:{{{unit_class}}}]] How does one do this properly? 209.16.118.178 (talk) 15:01, 16 September 2014 (UTC)
- If you mean placing the page in a category then [[Category:{{{unit_class}}}]] is correct syntax (it requires {{{unit_class}}} to have a value), and the problem must lie elsewhere if it doesn't work for you. If you mean creating an inline link at the place of the code then you must place a colon in front of the category name like
[[:Category:{{{unit_class}}}]]
. This is a general category feature unrelated to templates. For example,[[:Category:Wikipedia help]]
produces Category:Wikipedia help without placing this talk page in the category. PrimeHunter (talk) 15:21, 16 September 2014 (UTC)
- Thanks for your reply. An example is at http://gow-fireage.wikia.com/wiki/War_Elephants notice in the infobox, on the right, with the field labeled "Type"? You see it blank, which I dont'get, see the Template:Unit at http://gow-fireage.wikia.com/wiki/Template:Unit?action=edit Enorl76 (talk) 18:47, 16 September 2014 (UTC)
- As mentioned, if you want to display an inline link to the category in the infobox then you must place a colon in front like
[[:Category:...]]
. If you both want to display the category link in the infobox and place the page in the category then you must do both:[[:Category:...]][[Category:...]]
. Currently the template only says[[Category:...]]
. That isn't supposed to display anything where the code is placed. It only places the article in the category and places a link to the category at the bottom of the article. All of this is basic category features and unrelated to templates and parameters. See Help:Category. PrimeHunter (talk) 22:58, 16 September 2014 (UTC)
- As mentioned, if you want to display an inline link to the category in the infobox then you must place a colon in front like
Earlier today this template began appearing malformed on articles (e.g. Next United Kingdom general election, German federal election, 2013). The template itself has not been edited since December last year, so I assume an underlying template has been broken. Can anyone help out? Please comment at Template talk:Infobox election. Cheers, Number 57 10:58, 6 October 2014 (UTC)
- This has been resolved. -- John of Reading (talk) 11:33, 6 October 2014 (UTC)
Good faith confusion about includeonly
@Redrose64: Umm you've got a point. https://en.wikipedia.org/w/index.php?title=Help%3ATemplate&diff=633884924&oldid=633884024 Apologies. I will correct this on the transclusion page. --Mrjulesd (talk) 01:37, 15 November 2014 (UTC)
Templates showing
All templates seem to be collapsed right now? WikiOriginal-9 (talk) 21:15, 12 December 2014 (UTC)
- I'm not seeing this. Looking through your recent contributions for clues, I found and fixed an error in the Going postal article - was that the problem you were referring to? -- John of Reading (talk) 22:12, 12 December 2014 (UTC)
- All the navboxes I come across are all expanded (fully visible) - (I didn't mean to say collapsed earlier) and the show button is missing. WikiOriginal-9 (talk) 22:22, 12 December 2014 (UTC)
- I'm not seeing that either. Do you have JavaScript turned off in your browser? [I'm about to go offline, BTW]. -- John of Reading (talk) 22:37, 12 December 2014 (UTC)
- Thanks, it's fine now. I had it on though, so idk. WikiOriginal-9 (talk) 22:47, 12 December 2014 (UTC)
- I'm not seeing that either. Do you have JavaScript turned off in your browser? [I'm about to go offline, BTW]. -- John of Reading (talk) 22:37, 12 December 2014 (UTC)
- All the navboxes I come across are all expanded (fully visible) - (I didn't mean to say collapsed earlier) and the show button is missing. WikiOriginal-9 (talk) 22:22, 12 December 2014 (UTC)
Help creating a template for Encylcopedia Virginia listings
I have a quick question: would it be possible to create a template for Encyclopedia Virginia articles akin to how we have templates for listings at IMDb or Find-A-Grave? (IE, like this: {{IMDb title| xxxxx }}) The reason I'm asking is that there are a lot of articles at EV that have articles on here and it'd be a valid external link for these articles since the EV would be able to have links to various multimedia and whatnot that might not be available on Wikipedia. Plus they can go into more minutae than we can on here and it's a reliable source (vetted and all) so it'd be a useful external link. (If you're curious, here's a link to the entry for St. George Tucker to show what I mean by multimedia and such.) I can do without it, but I've never created anything of this nature before and it'd just be something nice to have. (Full disclosure, I'm Tokyogirl79 editing under a different name for my volunteer position at the Library of Virginia.) Tokyogirl79LVA (talk) 16:37, 4 March 2015 (UTC)
Looking for a counting template
I make regular edits to a page on Wikipedia, which includes a table, and a count of the number of rows in that table. It is common for someone to add/remove a row in the table without updating the manual count. I've developed a template that keeps a count of how often it is transcluded on the page, but I wanted to know if one already existed. What would be a good name for it ("count" is already in use)? -- Jevanyn talk 20:05, 15 April 2015 (UTC)
- Jevanyn, where is the template? Frietjes (talk) 13:41, 25 April 2015 (UTC)
- On another wiki. The main use case is on Wikipedia, though, on the List of oldest living people. There is a table of names that many users add/remove records in, but the text specifies how many men and women are listed, which frequently gets out of sync. I wanted to replace the "F" and "M" with ((count|F)) and ((count|M)), and put the counted totals in the text after the table. My question here was primarily what to call the templates so that they can be easily found and reused. -- Jevanyn talk 20:36, 27 April 2015 (UTC)