Template:Generic Merit Badge

From Saintapedia
Revision as of 08:25, 13 September 2024 by Tom (talk | contribs) (Text replacement - "Category:Help" to "Category:HelpCategory:Help under review")
Jump to navigation Jump to search
[[Image:{Template:Image | center | 49px]] TEXT

Generic userbox template, used as a template to build other user badge templates or directly (not recommended) to place a custom badge on a page .

Usage

To create a new custom badge based on this template, either as a new template or for one-time use on your user page, paste the following code into the page, then complete each of the parameters as indicated. For parameters where you accept the default value (e.g. fontcolor=black) you can delete that line from the template call on your page.

Generally, it is preferred to create a new badge template than to call the GMB template directly on a user page. This allows others to use the same badge, and, since the badge should assign a relevant category to all users, allow a community-building tool to result from that category.

Be sure to name the new template page as Template:User Badgename and not User Badgename. This is a common error people make when creating a new badge. If you have already made this mistake, you do not need to create the new Template: page. Instead, open the mis-named User Badgename page, and select the "move" tab at the top (next to the "history" tab), and move the page to Template:User Badgename.

Template Code

Take advantage of Template:GMB to create the badge. When creating a new badge, open your newpage called Template:User Badgename and place this code on that page:

{{subst:GMB}}

then save the page.

Reopen the page, and you will see that the subst: code (above) has been replaced by the badge template code, including a basic user instructions section. Delete the lines

<<pre>>

and

<</pre>>

Fill in the needed values after each =. See below in the Parameters section for instructions for each variable. Be sure to edit the categories and phrases in the instructions. Do not change the {{PAGENAME}} coding; that will work properly in the final page.

Parameters

  • text (or first parameter) (required) is what you want to appear on the right — this can include Wiki links and formatting . See below for customizing options.
  • image (or second parameter) (required) is the jpg/gif/png you want to use — do not use the Image: in front of the image file name.
  • imagesize is the image width in pixels — must include the px (default 49px). Left box will change size to accommodate the value you specify here.
  • imagepadding is the image left/right padding width in pixels — must include the px (default 2px).
  • color1 is the right box background color (default white)
  • color2 is the left box background color (default white).
  • fontcolor is the color to be used for the text (default black).
  • bordercolor is the color to be used for the solid border around the box (default black).
  • category is the category (if any) that will be applied to a page that includes this template (default none). Simply give the category name; do not use Category:. If you are creating a new category along with a new badge, use the convention for the category name as Organization Users rather than the badge name convention of User Organization.
  • sortkey is the page's sort key on the category page (default {{PAGENAME}}).
  • nocat is used when calling a badge made with the template; not when building a new badge from the template. Set it to non-empty if the category and include_text should not be applied in this case. If you are building a badge template using the GMB template, leave this line out of the GMB template call. If you are placing a GMB-based badge on a page for illustration purposes on a page, but do not want the default categories from either the |category= or |include_text= lines applied to that page, then include |nocat=true or |nocat=1 in the badge template call.
  • include_text is any other <includeonly> text you wish to accompany the badge. Text placed here will appear immediately below the badge itself. If you have more than one category to assign when the badge is used, you can include the additional category code here in the standard form of
  • <noinclude> This opening code must stay flush and on the same line with the }} closing braces to ensure proper spacing of the badge on user pages. The rest of usage instructions and template categories can be formatted normally in this section.
  • Box size options It is also possible to change the |height= and |width= values for a merit badge by adding those lines to the code from above. However, this is generally not recommended, because the resultant badge would be a different size from other template-based badges on the user page and throw the badge layout off.

Colors

Colors can be expressed simply by name such as blue, RGB notation such as rgb(256,128,0), or hex code such as #3322BB.

For the safest web colors, see HTML Color Chart. For more color options, see Web Colors.}.

Assigning Categories for Badges Users and for Badges

Intellipedia is organized using multiple techniques, including categories, hyperlinking, and page namespaces. This section discusses the selection and assignment of categories when building userbox templates. For general information: the hyperlinking technique is the obvious linking of iPed pages to one another, using the code format of [[Page Name]]; the page namespace technique is the naming of certain types or pages with standard forms such as User:user.name, Intellipedia:iPed_Topic, Portal:Organization_Name, Help:iPed_Topic, Template:action name, and Category:Category name.

A page can be in only one namespace, since the term is embedded in the page name itself. If you need to have the same content in more than one namespace, create the page under the most useful namespace, and then transclude that page in an additional page named in the alternate namespace.

Categories are a much more flexible tool for organizing information in Intellipedia, since a page can be assigned to multiple categories. Further, iPed automatically builds the category page, listing all pages assigned to the category. You assign a category to a page by including somewhere in the page (usually at the very bottom of the page, for ease of finding and editing) the code . Every iPed page should be marked with appropriate categories. Categories themselves should be categorized, so that they fall into a structured hierarchy down from the top level categories.

When building a new merit badge or userbox template, there are two separate category types to consider: Intellipedian categories, to be assigned to anyone who places the badge on their User: page; and userbox template categories, to be assigned to the template page itself.

Userbox Template Categories

Userbox templates themselves are organized by being assigned to template sub-categories. When creating a new merit badge template, look for the appropriate template sub-category, usually, but not always, found under Category:Userbox Templates, and assign it to the template page. To do this, place the code for the template category inside the noinclude section of the page, generally just before the closing </noinclude> line. Try to identify an appropriate sub-category, such as Category:Academic institution user templates or Category:Company Templates, avoiding using the Category:Userbox Templates category directly. In general, it should not be necessary to create a new template sub-category.


Initializing the Category: Page

When you create a new category, Intellipedia will automatically generate the list of all pages marked with that category. However, the Category: page itself, which will display that list, has to be initialized, the first time anyone calls it up. Once you have saved the new badge template page, set up the new Category page for other users. At the bottom of the badge template page should be a link to the category, usually in red text to indicate the page does not yet exist. Click on that link to open the new category page, ready to edit. Add three items to the page: a display of the associated merit badge, a short description of who are members of the category, and the category assignment for that category, itself.

To display the merit badge with a link to the template page itself, use the following code:

{|
|{{Badge display|User Badgename}}
|}

For the category assignment of the category itself, look for an appropriate one to fall into the heirarchy drill down on Category:Top_Level. For assistance, look at other Category: pages to see how they are assigned.

Optional or Customizing Parameters in the Text

You can give badge users more flexibility in content by defining optional parameters and default text for those parameters. You can have more than one option within the text.

Freeform Options

Within the text, each option is identified by triple braces, and consists of the parameter name followed by the default text, separate by pipe. Thus, the text portion of the badge code could appear as

text={{{option1 |This is the first part}}} of the {{{option2 |custom badge name}}} text.

Be careful to include all the appropriate text inside the option default, lest it cause problems when a user customizes the badge. For instance, use

text={{{myname |This '''Intellipedian'''}}} is a Fanfan.

and not

text=This {{{myname |'''Intellipedian'''}}} is a Fanfan.

The best way to include category code in a badge is in the |category= line, or in the include_text= line. However, it is possible to embed category code in the text; in general this should not be done unless using the #switch option as described below. For freeform options, place the code in the base text content, and not inside the option default code. Otherwise, when users customize the badge, the category will be missing from their pages.

text={{{myname|This '''Intellipedian}}} is a Sox Fan.

and not

text={{{myname|This '''Intellipedian}}} is a Sox Fan.

If there are multiple options in the template, then the end user code can include one or more as customized, separated by pipes. Options not specified by the user result in the default text. An end user might code a custom badge that has three options, but customize only two, with

{{User Badgename |option1= My real name |option3=my home state}}

resulting in a badge with the default text from option2.

Pre-defined Options

In addition to defining options by name and providing users with a choice of either accepting the default value or typing their own content, you can set an option with a list of pre-defined values. Users select which value to use by typing only the key number of their selection.

Inside the text code, you combine the #switch command template (double braces, {{#switch:{{{option|}}}| ...values... }} with the parameter definition code (triple braces, {{{option1|... }}} , as above), resulting in code in the format of

{{#switch: {{{option|}}}|1=value1|2=value2|#default=default value }}

Note the option is defined with the pipe (|) in the definition, but no default value; the pre-defined options are then defined for the #switch command. It is best to include the #default value in this set. Note that any defined value can be set to null with |#3=.

Be sure to document all of these pre-defined options on the template page for the user to see. Do not expect them to open the edit view and discover the options on their own. A simple instruction could be

You can set your status to any of three values by including one of these lines in your template call:
: |status=1  
for is assigned to
: |status=2  
for was assigned to
: |status=3  
for supports

Also, note that because you have tighter control over the occurrence of category codes in the text when using the #switch you can include alternative categories in the code, and they will be assigned properly on user pages. Thus, expanding the above example,

You can set your status to any of three values by including one of these lines in your template call:
: |status=1  
for is assigned to
: |status=2  
for was assigned to
: |status=3  
for supports

Embedding Links

You can add a fancy touch to your badges by embedding web page links in the text. The obvious and simple method, using just a single bracket set and the URL with the linked text causes two format problems. First, the linked text will be the color of standard links on the page, failing to match the badge fontcolor. Second, when inside a badge, the link will have a little arrow character next to it. However, you can override both of these situations with a bit of extra code.

[http://www.intelink.gov/wiki Intellipedia Home Page]'

results in Intellipedia Home Page

but

<span class="plainlinks">[http://www.intelink.gov/wiki <font color=black>Intellipedia Home Page</font>]</span>

results in the linked text Intellipedia Home Page

Example

For an example of a user badge that incorporates a freeform text parameter, a predefined option set text parameter, and an embedded link in the text, see the User NGB template.

Note not only the coding in the badge, but also the user instructions and examples on the template page.

Multi-Use Badges

In the past, some users have created a set of separate badge templates to cover various statuses or relationships with an organization or community. See, for example, the USMC badges:

By using the text options described above, you can simplify badge use my creating a single badge that allows for customizing to different statuses.

The simplest way to do this is with a free form text option, allowing the user to specify any wording desired on the badge. See, for example,

A more elegant solution is to set up pre-defined options, to standardize the wording on all like-status badges. This method also allows you to establish separate sub-categories for each status option. Be sure to consider all likely options users may want, and to provide clear instructions on the template page. Do not expect users to open the template edit page to inspect the code and discover available options.

For an example with multiple defined options, sub-categories, and full usage instructions, see

Provide Instructions for the Users

Content described here belongs in the <noinclude> ... </noinclude> section of the pasted template code from above.

If you use the {{GMB}} template as described above in the Template Code section, most of the standard instructions are put on the page for you. You will have to edit them a little.

Minimum Guidelines

The minimum usage instructions on every badge template page should be to tell users to use the default template call code, instead of copying the badge code and pasting it into their pages.

Document Options

If you provide a badge with options, be sure to document their existence, and how to use them, on the template page. Don't simply declare the parameter and show the triple-brace code. (That information is for badge designers, not users.)

Instead, declare the parameters and give examples of how an end user can use them.

Sample Instructions

To use this badge as shown above on your page, use the code
{{User Badgename}}
Unless you need to customize your badge beyond the options available here, do not paste the raw badge code from this template into your page. You can customize your own badge by changing the following options...

Examples of how to show such usage instructions can be seen on the badge templates

Template:User CISSP and
Template:User USC.

Template Categories

Be sure to apply the appropriate template categories to your new badge template by including the code here.

Inspiration

User Edit Count Merit Badge.


Examples

[[Image:{Template:Image | center | 49px]] My text
{{Generic Merit Badge
 |color1=green
 |color2=#FF33BB
 |fontcolor=#FFFFFF
 |bordercolor=
 |text=My text
}}
[[Image:{Template:Image | center | 49px]] My text
{{Generic Merit Badge
 |color1=MediumAquamarine
 |bordercolor=#3322BB
 |image=OSC-Icon.gif
 |imagesize=
 |imagepadding=12px
 |text=My text
}}
[[Image:{Template:Image | center | 49px]] My much longer text that runs over several lines and needs to be displayed in such a manner that people can read it easily
{{Generic Merit Badge
 |color1=yellow
 |color2=
 |bordercolor=rgb(0,256,128)
 |image=Gardeningspade.jpg
 |text=My much longer text that runs over several
lines and needs to be displayed in such a manner
that people can read it easily
}}
[[Image:{Template:Image | center | 49px]] For a badge with option text, This is where i put my name

and this is where I say where I live.

{{Generic Merit Badge
 |color1=purple
 |fontcolor=yellow
 |bordercolor=dark blue
 |text=For a badge with option text, 
{{{myname|This is where i put '''my name'''}}} 
and {{{myhome|this is where I say where ''I live''.}}}
}}