FANDOM


  • See:

    With link:

    Canada

    Without link:

    4,608

    I would like the template in this form:

    • {{Box|NAME|URL}}

    If no URL is entered as a parameter, then the "name" is unlinked.

    I want to use this template in other places too. --Timeshifter (talk) 00:18, November 21, 2017 (UTC)

      Loading editor
    • <span style="border:3px solid red; border-radius: 10px; background:yellow; color:black; padding:2px;">'''{{#if:{{{URL|}}}|[{{{URL}}} <span style="color:blue;">{{{NAME|}}}</span>]|{{{NAME}}}}}'''</span>

      note: all urls supposed to be external (http:...).

        Loading editor
    • Thanks Fngplg. I must be doing something wrong. Please see:

        Loading editor
    • Fngplg. I want to use this template in other places too. For use by other editors besides me. It would be easier for them if it used unnamed parameters. In its current form it needs named parameters:

      With link:

      • {{Box|NAME=Canada|URL=http://en.wikipedia.org/wiki/Health_care_in_Canada}}

      Without link:

      • {{Box|NAME=4,608}}

      I would like the template to use unnamed parameters:

      With link:

      • {{Box|Canada|http://en.wikipedia.org/wiki/Health_care_in_Canada}}

      Without link:

      • {{Box|4,608}}
        Loading editor
    • Just replace all URL by 2 and all NAME by 1, I tested the effect on w:c:Cannabis:Template:Box/sandbox: Maybe add class="plainlinks" if you want no "external link" arrow for the URL. Maybe catch the third case "no parameter at all" as I did on Box/sandbox with a {{{1|<strong style="color:red">FIXME</strong>}}}.

        Loading editor
    •   Loading editor
    • I went ahead and added class="plainlinks" to Template:Box to get rid of the arrow at the end of the link. The arrow sometimes wraps to the next line in tables.

        Loading editor
    • Is it possible to make this template so that it can use a wikilink too? And not just a URL. For example; local wikilinks, and Wikipedia wikilinks:

      [[Canada]]

      [[wikipedia:Health care in Canada|]]

      Health care in Canada

      So the template could use wikilinks also:

      {{Box|Canada|[[wikipedia:Health care in Canada|]]}}

      instead of always having to use the full URL:

      {{Box|Canada|http://en.wikipedia.org/wiki/Health_care_in_Canada}}

        Loading editor
    • try

      <span style="border:3px solid red; border-radius: 10px; background:yellow; color:black; padding:2px;">'''{{#if: {{{2|}}
                         | {{#if: {{#pos: {{{2}}} | ://}}
                             | [{{{2}}} {{#if: {{{1|}}} | <span style="color:blue;">{{{1}}}</span>}}]
                             | [[{{{2}}} {{#if: {{{1|}}} | {{!}} {{{1}}}}}]]
                           }}
                         | {{{1|}}
                       }}'''</span>
      
        Loading editor
    • Thanks. I did some tests here:

      It is not working for local wikilinks. It is the local wikilinks that I would like to get working:

      • {{Box/sandbox2|Canada|[[Canada]]}}

      Wikipedia links are not important to me. I can use full URLs for them.

      I set up an empty sandbox if you want to try out some more ideas:

      The current working template is here:

      It uses class=plainlinks

        Loading editor
    • it seems like tail wagging the dog. why u don't use [[link|{{myappearance|theme|text}}]]?

        Loading editor
    • I am trying to keep the template multi-purpose and as simple as possible. So that others can use it easily too.

        Loading editor
    • For local wiki links, leave out the brackets. For example:

      {{Box/sandbox2|Canada|Canada}}

      If fact, I added a bit more. You should be able to get away with:

      {{Box/sandbox2||Canada}}

        Loading editor
    • Timeshifter wrote:

      I am trying to keep the template multi-purpose and as simple as possible.
      It's slightly odd to protect a /sandbox subpage ;-P
        Loading editor
    • The thought just occurred to me that you probably want the internal links to be blue as well. In that case, you the following instead. In order for the color change to be applied, you will need to provide the first parameter.

      <span style="border:3px solid red; border-radius: 10px; background:yellow; color:black; padding:2px;">'''{{#if: {{{2|}}
                         | {{#if: {{#pos: {{{2}}} | ://}}
                             | [{{{2}}} {{#if: {{{1|}}} | <span style="color:blue;">{{{1}}}</span>}}]
                             | [[{{{2}}} {{#if: {{{1|}}} | {{!}} <span style="color:blue;">{{{1}}}</span>}}]]
                           }}
                         | {{{1|}}
                       }}'''</span>
      
        Loading editor
    • Looking good. I added class=plainlinks and adjusted some padding. See sandbox3. The only thing missing is a good result if only an unlinked single parameter is given. For example; a dollar amount: $4608.

      I am protecting the old sandboxes so that this thread makes sense to others, and so continual improvement can be seen, and improved upon.

      The unlinked single-parameter text needs to be bold black, and not blue. See $4608 in the main template:

        Loading editor
    • Sorry about the last template version. I made some noob typos that caused it to malfunction.

      As you can tell, I edited the new sandbox page. For the template, it now contains:

      <span style="border: 3px solid red; border-radius: 10px; background-color: yellow; color: black; padding: 2px;">{{#if: {{{2|}}}
        | '''{{#if: {{#pos: {{{2}}} | ://}}
            | <span class="plainlinks">[{{{2}}} {{#if: {{{1|}}}
                | <span style="color: blue;">{{#ifeq: {{{1}}} | {{!}}
                    | {{{2}}}
                    | {{{1}}}
                  }}</span>
              }}]</span>
            | [[{{{2}}} {{!}} <span style="color: blue;">{{#if: {{{1|}}}
                | {{#ifeq: {{{1}}} | {{!}}
                    | {{#sub: {{{2}}} | {{#expr: 1+{{#pos: {{{2}}} | :}}}}}}
                    | {{{1}}}
                  }}
                | {{{2}}}
              }}</span>]]
          }}'''
        | {{#if: {{{1|}}}
            | '''{{{1}}}'''
          }}
      }}</span>
      
      Intended Behaviors First Parameter
      Nothing Vertical Bar Character Other
      Second Parameter Nothing empty yet visible span element a black and bold vertical bar character a black and bold version of the first parameter's input
      External default plainlink behavior plainlink with entire URL as blue and bold text plainlink with first parameter's input as blue and bold text
      Internal or Interwiki similar to basic link but with blue and bold text similar to the link pipe trick but with blue and bold text link with first parameter's input as blue and bold text
        Loading editor
    • Fantastic. Following the logic of your table, I added more tests here:

        Loading editor
    • Some of your examples don't line-up with what you used. In order to pass the vertical bar character, you will need to use the template {{{!}}}. Right now, the tempalte doesn't handle users putting the link brackets around the second parameter. If that is something you would like to protect against, I can make the necessary adjustments.

        Loading editor
    • I deleted this comment of mine.

        Loading editor
    •   Loading editor
    • I have no idea what any of that means. :)

        Loading editor
    • Timeshifter wrote: I have no idea what any of that means. :)

      It means that you can detect the existence of [[User:Timeshifter]] with parser-function '''{{#ifexist:User:Timeshifter|gotcha|found no User:Timeshifter here}}''' rendered as gotcha, notably '''{{#ifexist:[[User:Timeshifter]]|gotcha|oops}}''' ends up as oops.
        Loading editor
    • I deleted this comment of mine.

        Loading editor
    • did u have a look at #21?

        Loading editor
    • Fngplg wrote: did u have a look at #21?

      Not what you wanted to know, but I looked at it and decided that using Lua/Scribunto/Module to get a better replace than the existing parser function #replace: is about 1000 miles above the level where users explore the secrets of Help:Page protection#Advice.Face-tongue

        Loading editor
    • I put the tests in several different tables. See:

      Mainly, I would like consistency. It might be better to simplify everything to the capabilities of the top table.

      The output of the following tables should then come back as "fix me" or "remove brackets", and so on. Or show only the border with nothing inside. Same as if no parameters entered.

        Loading editor
    • Fngplg, Dunnoob, and all. Feel free to create more sandboxes if you want to experiment.

        Loading editor
    • experiment with what? did u see solution provided in #21?

        Loading editor
    • I don't understand anything in #21. Please set it up in one of my user sandboxes. Here is one just for you:

      Then give me some examples of it working.

      {{box|TEXT|LINK}}
        Loading editor
    • I am a bit confused as to the exact conversation but I believe Dunnoob is correct. Using Lua is unnecessary. Try the following:

      <span style="border: 3px solid red; border-radius: 10px; background-color: yellow; color: black; padding: 2px;">{{#if: {{{2|}}}
        | '''{{#if: {{#pos: {{{2}}} | ://}}
            | <span class="plainlinks">[{{#replace: {{#replace: {{{2}}} | ] |}} | [ |}} {{#if: {{{1|}}}
                | <span style="color: blue;">{{#ifeq: {{{1}}} | {{!}}
                    | {{#replace: {{#replace: {{{2}}} | ] |}} | [ |}}
                    | {{{1}}}
                  }}</span>
              }}]</span>
            | [[{{#replace: {{#replace: {{{2}}} | ] |}} | [ |}} {{!}} <span style="color: blue;">{{#if: {{{1|}}}
                | {{#ifeq: {{{1}}} | {{!}}
                    | {{#if: {{#pos: {{{2}}} | :}}
                        | {{#replace: {{#sub: {{{2}}} | {{#expr: 1+{{#pos: {{{2}}} | :}}}}}} | ] |}}
                        | {{#replace: {{#replace: {{{2}}} | ] |}} | [ |}}
                      }}
                    | {{{1}}}
                  }}
                | {{#replace: {{#replace: {{{2}}} | ] |}} | [ |}}
              }}</span>]]
          }}'''
        | {{#if: {{{1|}}}
            | '''{{{1}}}'''
          }}
      }}</span>
      

      Note that this version also has been corrected to deal with the case in which the first parameter is the vertical bar character but the second is an internal/interwiki link without a colon. The previous version would throw an error while this one behaves as expected; doesn't remove anything.

      I can change the behavior of the first parameter for external links if you really want but I thought it might be a good idea to keep it as close to the regular link behavior as possible. For external links, not providing link text goes something like this:

      [http://www.google.com ]
      

      [1]

      There is not way to specify that the link text should be the URL. Instead, that is done by simply typing the URL.

      http://www.google.com
      

      http://www.google.com

      Thus, how I reached my decision on which behavior to associate with the vertical bar. But again, let me know if you really want it swapped.

        Loading editor
    • I think something is wrong. Here is the result when pasted in sandbox4:

        Loading editor
    • Hmm... This appears to be a bug in the parser function.

      {{#replace: [[[[Uh]]]] | ]]]] |}}
      
      {{#replace: [[[Well]]] | ]]] |}}
      
      {{#replace: [[Hello]] | ]] |}}
      
      {{#replace: [There] | ] |}}
      

      [[[[Uh

      [[[Well

      [[Hello

      [There

      {{#replace: [[[[Uh]]]] | [[[[ |}}
      
      {{#replace: [[[Well]]] | [[[ |}}
      
      {{#replace: [[Hello]] | [[ |}}
      
      {{#replace: [There] | [ |}}
      

      {{#replace: [[Uh]] | [[[[ |}}

      {{#replace: [[[Well]]] | [[[ |}}

      {{#replace: Hello | [[ |}}

      There]


      Edit:

      Duh! There is an easy fix. I already adjusted my previous response. Re-copy the code and it should work.

      Not sure if we should still report this though.

        Loading editor
    • Thanks for all your work. It looks like everything works except a full URL by itself. Whether it is in the first or second parameter spot.

      If the full URL is in the second parameter spot I am guessing it is difficult to force the blue text color to override the default color for the number.

      If the full URL is in the first parameter spot it looks like it is hard to force it to be unlinked.

        Loading editor
    • Yes. Unfortunately, those two cases have to do with the base behavior of external links. While it is possible to change them, it would require bringing site CSS into the picture.

      .red-yellow-link-box a.external.autonumber,
      .red-yellow-link-box a.external.free {
          color: blue;
      }
       
      .red-yellow-link-box a.external.free::after {
          display: none;
      }

      You would then also need to modify the template.

      <span class="red-yellow-link-box" style="border: 3px solid red; border-radius: 10px; background-color: yellow; color: black; padding: 2px;">the other stuff here</span>
      

      In fact, if you are going to add the class to style those external links, you might as well move all the CSS to the style sheet.

      .red-yellow-link-box {
          border: 3px solid red;
          border-radius: 10px;
          background-color: yellow;
          color: black;
          padding: 2px;
      }
       
      .red-yellow-link-box a.external.autonumber,
      .red-yellow-link-box a.external.free {
          color: blue;
      }
       
      .red-yellow-link-box a.external.free::after {
          display: none;
      }

      Then, for the template:

      <span class="red-yellow-link-box">the other stuff here</span>
      

      Edit:

      Even better:

      .red-yellow-link-box {
          border: 3px solid red;
          border-radius: 10px;
          background-color: yellow;
          color: black;
          padding: 2px;
      }
       
      .red-yellow-link-box a[href] {
          color: blue;
      }
       
      .red-yellow-link-box a.external::after {
          display: none;
      }

      Then the template should simplify to:

      <span class="red-yellow-link-box">{{#if: {{{2|}}}
        | '''{{#if: {{#pos: {{{2}}} | ://}}
            | [{{#replace: {{#replace: {{{2}}} | ] |}} | [ |}} {{#if: {{{1|}}}
                | {{#ifeq: {{{1}}} | {{!}}
                    | {{#replace: {{#replace: {{{2}}} | ] |}} | [ |}}
                    | {{{1}}}
                  }}
              }}]
            | [[{{#replace: {{#replace: {{{2}}} | ] |}} | [ |}} {{!}} {{#if: {{{1|}}}
                | {{#ifeq: {{{1}}} | {{!}}
                    | {{#if: {{#pos: {{{2}}} | :}}
                        | {{#replace: {{#sub: {{{2}}} | {{#expr: 1+{{#pos: {{{2}}} | :}}}}}} | ] |}}
                        | {{#replace: {{#replace: {{{2}}} | ] |}} | [ |}}
                      }}
                    | {{{1}}}
                  }}
                | {{#replace: {{#replace: {{{2}}} | ] |}} | [ |}}
              }}]]
          }}'''
        | {{#if: {{{1|}}}
            | '''{{{1}}}'''
          }}
      }}</span>
      

      Edit:

      And yes, unlinking would require site JS; which I cannot help you with. However, Fngplg might be able to.

        Loading editor
    • Timeshifter#30
      I don't understand anything in #21.

      sandbox updated. use source mode to see input parameters. w:c:dev:User:Fngplg/sandbox; template: w:c:dev:User:Fngplg/sandbox/1; required: w:c:dev:module:string
        Loading editor
    • Can an admin delete my post when I forgot to sign in? That post is messed up anyway. I wish the page would warn us when that is about to happen.


      I think the template with the CSS built in to the template is easier to pass on to other wikis that I am not involved in. The separate CSS page makes things more complicated.

      I have been thinking about a few other things too.

      On one page I may use this template a hundred times. For example; city lists. So I want to keep the template code as simple as possible in order to avoid slowing down the loading of the page.

      Bare URLs are not important, and I can not see a reason now that I would want a box around a linked or unlinked bare URL. So, let's avoid adding that additional code.

      Currently, I have multiple templates set up for box, redbox, greenbox, magentabox, orangebox, etc.. That is for the border color. Background color remains yellow.

      Can I add a third parameter for color?:

      {{box|TEXT|LINK|COLOR}}

      That would save me from having to change the code in multiple templates every time I update the code. I would have only one template.

      If no color parameter is added, then the default border color would be red.

        Loading editor
    • It would be better to ask an admin on their message wall. They are not likely to see your request here.


      You should be able to use it multiple times. Whether or not there is a limit, I don't know. Depending on how you are generating the list, it might be possible to have MediaWiki apply the template for you rather than having multiple explicit template calls. However, I would need a more concrete example of how you intend to use it. As for not slowing down page loading, having the site CSS would be better.

      Okay, I'll remove it. However, the only bare URL capability intentionally placed in the template is the result from using a vertical bar character as the input for the first parameter. Another case which could result in a bare URL is if the URL is passed as the first parameter with no second parameter. A third case would be if the URL is passed to both the first and second parameters. I could write around these but that would add to the template.

      Yes, I'll add it. Note that you should be able to use hex color values in addition to names.

      <span style="border: 3px solid {{#if: {{{3|}}} | {{{3}}} | red}}; border-radius: 10px; background-color: yellow; color: black; padding: 2px;">{{#if: {{{2|}}}
        | '''{{#if: {{#pos: {{{2}}} | ://}}
            | <span class="plainlinks">[{{#replace: {{#replace: {{{2}}} | ] |}} | [ |}} {{#if: {{{1|}}}
                | <span style="color: blue;">{{{1}}}</span>
              }}]</span>
            | [[{{#replace: {{#replace: {{{2}}} | ] |}} | [ |}} {{!}} <span style="color: blue;">{{#if: {{{1|}}}
                | {{#ifeq: {{{1}}} | {{!}}
                    | {{#if: {{#pos: {{{2}}} | :}}
                        | {{#replace: {{#sub: {{{2}}} | {{#expr: 1+{{#pos: {{{2}}} | :}}}}}} | ] |}}
                        | {{#replace: {{#replace: {{{2}}} | ] |}} | [ |}}
                      }}
                    | {{{1}}}
                  }}
                | {{#replace: {{#replace: {{{2}}} | ] |}} | [ |}}
              }}</span>]]
          }}'''
        | {{#if: {{{1|}}}
            | '''{{{1}}}'''
          }}
      }}</span>
      
        Loading editor
    • I left a note on an admin's message wall.

      The latest template code with the third parameter for color is working great for the most part. See:

      Except this one shows no border color:

      • {{Box/sandbox4|Canada|[[Canada]]}}
        Loading editor
    • Andrewds1021 wrote:

      <span style="border: 3px solid {{#if: {{{3|}}} | {{{3}}} | red}}; …</span>
      
      Minor nit, parser functions have a cost, there's a limit how many you can have per page. This snippet can be simplified:

      <span style="border: 3px solid {{{{3|red}}}; …</span>.

        Loading editor
    • Aren't the pages cached at the server level? So that once it has been created at the HTML level, the page is served up without further parser usage?

      In any case I want to use the simplest template code that works for my needs. I am trying to make a multi-purpose template that can be used on Wikia for my uses, and also be used by new editors to add cities here too:

      The simplest is that someone enters a city name in the first and second parameter spot in the template. Even simpler if they figure out to use double bars followed by the city name once. That then links in a colorful way to the local wiki city page.

        Loading editor
    • Timeshifter wrote: Aren't the pages cached at the server level?

      Sure, and I can't tell if something like the mw:Category:Pages with too many expensive parser function calls maintenance category would be automatically populated here; it certainly was deleted here and is empty at the moment. Maybe the ancient MediaWiki 1.19 used here doesn't have this tracking feature, presumably #if: never counts as expensive, but the effect on a page with numerous parser functions is disastrous (example): Above the "too many" limit further expensive parser functions on a page are simply ignored.
        Loading editor
    • Are any of these expensive parser functions being used in our template:

      "At the current time, there are only four expensive Parser Functions:..."

        Loading editor
    • MediaWikiWiki says default 99, affecting #ifexist: (see above) and Lua (maybe relevant for replace: instead of #replace:, see above), I don't know how to check this, I'm not aware of any reasons to change this on Wikimedia or FANDOM wikis, and I didn't know these $wgExpensiveParserFunctionLimit details five minutes ago.Smiley

        Loading editor
    • I think we are ok with our template. I don't see any expensive parser functions in it.

      Check out the huge number of {{#ifexist:}} in this template:

      I found it here:

        Loading editor
    • it's completely unrelevant. none of those templates uses expensive parser functions. there is no limits to use non-expensive calls itself. and u likely never will hit other limits. for instance, my template can be used >1000 times per page.

        Loading editor
    • Timeshifter wrote: Except this one shows no border color:

      • {{Box/sandbox4|Canada|[[Canada]]}}

      That is because what you actually have in the table for the output cell is {{Box/sandbox4|Canada|Canada|[[Canada]]}}.


      Dunnoob wrote: Minor nit, parser functions have a cost, there's a limit how many you can have per page. This snippet can be simplified:

      <span style="border: 3px solid {{{{3|red}}}; …</span>.

      As has already been pointed out by Timeshifter (#46) and Fngplg (#47), the current version of the template doesn't use any expensive parser functions so the limit is irrelevant. As for loading times, I believe Timeshifter has a valid point in #42. I am not sure why you bring up #ifexist in #45. I don't remember if they fixed it yet but a long standing problem with that parser function has been that it causes the page it searches for to be listed on Special:WantedPages even if it exists.

      Also, your proposed change is not the same as what I have. {{{param|default}}} does not behave identically to {{#if: {{{param|}}} | {{{param}}} | default}}. The difference in behavior occurs when whitespace is passed as the value for param. The first case (your alternative), evaluates to the white space that was passed to the parameter. The second case (what I am using), evaluates to the default value. This makes a difference in some cases. In the specific case we are considering, using the alternative would cause the border color to be unspecified; or worse, invalid. In the case of unspecified, it will instead use CSS's color property. In the case of invalid, as exemplified in my response to Timeshifter, browsers may choose to completely ignore the impacted property; thus causing a complete absence of the border.

        Loading editor
    • Andrewds1021 wrote:

      I am not sure why you bring up #ifexist in #45.
      I mentioned it in #23 as a possible alternative to string-functions in #21 for the purposes here, i.e., detect if a local page Canada exists for a given template parameter value Canada, or use a literal 4608 for a given template parameter value 4608, because a local page 4608 does not exist. Personally I'd solve it by KISS, if folks want 4608 they can use 4608, and if they want Canada they can write [[Canada]], the effect—if unwanted—is obvious.

      About {{#if:{{{3|}}}|{{{3}}}}|red}} vs. {{{3|red}}}:

      This makes a difference in some cases. In the specific case we are considering, using the alternative would cause the border color to be unspecified; or worse, invalid.
      Yes, it can be important, testing the effect here:
      code output
      <span style="border: 3px solid {{{3|red}}};border-radius: 10px; background-color: yellow; color: black; padding: 2px;">Canada</span> Canada
      <span style="border: 3px solid {{#if: {{{3|}}} | {{{3}}} | red}};border-radius: 10px; background-color: yellow; color: black; padding: 2px;">Canada</span> Canada
      <span style="border: 3px solid; border-radius: 10px; background-color: yellow; color: black; padding: 2px;">Canada</span> Canada

      Okay for an undefined 3rd parameter, for an intentionally empty 3rd parameter I'll wait for new experiments by Timeshifter: It's also a matter of taste, should the template handle all possible input errors and variants, or should it be as simple as possible. Sometimes a convoluted error handling can be replaced by don't try this  examples in the documentation (incl. test cases).

      Update: Added 3rd row for the intentionally empty case, see below. Unsurprisingly an unspecified border color is inherited.

        Loading editor
    • "if:3|3" has same behavior as "3|red". both does offer same (zero) protection against empty values. if u want to protect, u have to use "ifeq:3||default|do stuff".

      note: empty last value it is rare case, so "3|def" will be enough in most cases.

        Loading editor
    • Okay, I see where you were going with #ifexist now.


      I don't think {{#ifeq: {{{3}}} || default | do stuff}} will ever execute default. the reason being that whitespace is stripped from the parser function parameters. Therefore, you are testing to see if the third parameter is empty. Whitespace is not the same as empty. In the event the the third parameter is not specified, the interpreter uses literally {{{3}}}; thus, also not an empty string.

      Test Case: do stuff

      Edit:
      Okay, so, I was wrong about default never being used. Apparently, if you specify the parameter but just leave it empty that will work. However, leaving it unspecified will evaluate to do stuff. This is in contrast to {{#if: {{{3|}}} | do stuff | default}} which will evaluate to default both when unspecified and when left empty.
        Loading editor
    • Andrewds1021#51
      I don't think {{#ifeq: {{{3}}} || default | do stuff}} will ever execute default.

      {{{3|}}}, of course. it is always {x|} by default.

      however, i was wrong, mixed up with another null-string checking. both if:{3|}|stuff|def and ifeq:{3|}||def|stuff will work. still doesn't matter cuz 3 is last param, it's like nobody will use {t|1|2|}.

        Loading editor
    • I like my mistake. :) It showed me a way to get rid of the border altogether. I added examples here:

      I think we are done. :) Thanks!

      Am I using the final version in the sandbox?

        Loading editor
    • Yes, I believe your sandbox is fully updated (the template portion at least). It may be worth noting that another (valid CSS) way to get rid of the border is to set the color to transparent.

        Loading editor
    • I see. I added a transparent test. It makes for more highlighting around the text. See:

      It looks like the border is made the same color as the yellow inner background.

      I created a {{Box2}} template and moved the old template code there. I am using that now for the embedded healthcare template used on hundreds of pages.

      That way I can use this new template code on individual pages, and update it as needed without worrying about overloading the servers. I will be moving the new code to the {{Box}} template.

      I protected sandbox 4, and started sandbox 5 if anybody wants to experiment further. Let me know of more ideas or improvements.

        Loading editor
    • {{Box|LINK|COLOR|TEXT}}

      I would like a version of the template in the above format. In order to get rid of the double bar needed when creating simple city links:

      • {{box|New York City|COLOR}}

      versus the current method:

      • {{box||New York City|COLOR}}

      This will make it much easier for new editors dropping in to add city links. Color is not necessary to enter, since there is a default red color. So a new editor can create a link as simple as this:

      • {{box|New York City}}

      I set up sandbox 5 to test the new order of parameters:

        Loading editor
    • Done. The change was very simple; see here.

        Loading editor
    • That was quick! Thanks again! Looks perfect after I fixed my table errors.

      Besides using it on Wikia, it is in use here:

      Any future improvements, suggestions, ideas, etc. from anybody can be tried out here:

        Loading editor
    • Timeshifter wrote: {{Box|LINK|COLOR|TEXT}}

      After your decision to use positional 1,2,3,… parameters instead of named parameters near the begin of this thread—nothing wrong with that, only mixing positional+named parameters tends to confuse me—I'd put the least important positional parameter COLOR at the end; with its working default red omitting it is never critical.

      Otherwise this epic thread is now ready as script for a new FANDOM University video, and iff they put it on YouTube I could even watch it.Face-tongue

        Loading editor
    • It might be good to have different versions of this depending on its purpose.

      • {{Box|LINK|COLOR|TEXT}}
      • {{Box2|LINK|TEXT|COLOR}}
      • {{Box3|TEXT|LINK|COLOR}}

      That is what I have done:

        Loading editor
    • Up to you. But what I think Dunnoob was trying to get at was that if you use names parameters instead, users can provide the inputs in whichever order they want. That way, you can use the same template for all cases and nevery have to use a double pipe.

        Loading editor
    • That's interesting. I did not know that. So if I only enter "link=..." then I get a local wikilink in a box? If I only enter "text=..." I get unlinked bold black text in a box? If I only enter "color=..." I get the empty box with that border color?

      That sounds very useful for a box used by me, and not new editors. Would you convert the existing code to that and give me that code here, or in sandbox 6?:

      I will keep both methods (positional and named) as box and box2. Lot simpler than adding box3 and box4 in order to have a different order of parameter entry.

        Loading editor
    • The template portion should be all set. You will need to add the rest of the page though. I am putting it below as well.

      <span style="border: 2px solid {{#if: {{{color|}}} | {{{color}}} | red}}; border-radius: 7px; background-color: yellow; color: black; padding: 0 3px;">{{#if: {{{link|}}}
        | '''{{#if: {{#pos: {{{link}}} | ://}}
            | <span class="plainlinks">[{{#replace: {{#replace: {{{link}}} | ] |}} | [ |}} {{#if: {{{text|}}}
                | <span style="color: blue;">{{{text}}}</span>
              }}]</span>
            | [[{{#replace: {{#replace: {{{link}}} | ] |}} | [ |}} {{!}} <span style="color: blue;">{{#if: {{{text|}}}
                | {{#ifeq: {{{text}}} | {{!}}
                    | {{#if: {{#pos: {{{link}}} | :}}
                        | {{#replace: {{#sub: {{{link}}} | {{#expr: 1+{{#pos: {{{link}}} | :}}}}}} | ] |}}
                        | {{#replace: {{#replace: {{{link}}} | ] |}} | [ |}}
                      }}
                    | {{{text}}}
                  }}
                | {{#replace: {{#replace: {{{link}}} | ] |}} | [ |}}
              }}</span>]]
          }}'''
        | {{#if: {{{text|}}}
            | '''{{{text}}}'''
          }}
      }}</span>
      
        Loading editor
    • u can use
      {{{text|{{{1|}}}}}}, {{{link|{{{2|}}}}}} and {{{color|{{{3|}}}}}}
      {box|text|link|color} = {box|text=text|link=link|color=color} = {box|1=text|2=link|3=color}
        Loading editor
    • I set up the tables of tests here:

      Thanks again, Andrewds1021! Looks like it is working perfectly.

      Fngplg. I would probably screw up any system based on remembering what number to use. :)

      I protected sandbox 6. I started sandbox 7 for further experimentation by anybody:

        Loading editor
    • A FANDOM user
        Loading editor
Give Kudos to this message
You've given this message Kudos!
See who gave Kudos to this message
Community content is available under CC-BY-SA unless otherwise noted.