Help:Sabr parser functions

From SABR Encyclopedia

(Difference between revisions)
Jump to: navigation, search
(Example call)
Line 1: Line 1:
-
<code><nowiki>{{#sabr-lightbox-link}}</nowiki></code> is a custom parser function written by SABR staffer Peter Garver to generate links to pop up lightboxes in the Encyclopedia. It is a very simple parser function that takes up to four parameters and generates an anchor (A) tag in raw html.
+
<code><nowiki>{{#sabr-lightbox-link}}</nowiki></code> is a custom parser function written by SABR staffer Peter Garver to generate links to pop up lightboxes in the Encyclopedia. It is a very simple parser function that takes one to four parameters and generates an anchor (A) tag in raw html.
== Purpose ==
== Purpose ==

Revision as of 17:27, 15 October 2009

{{#sabr-lightbox-link}} is a custom parser function written by SABR staffer Peter Garver to generate links to pop up lightboxes in the Encyclopedia. It is a very simple parser function that takes one to four parameters and generates an anchor (A) tag in raw html.

Contents

Purpose

The parser function is needed in the Encyclopedia because mediawiki does not offer a mechanism for generating anchor tags with specific class and rev attributes. Both of these are required to use floatbox, the lightbox clone currently used in the Encyclopedia.

Parameters

The parser function automatically sets the class to "floatbox", and automatically links to an anchor within whatever page it's on. The parameters specify:

  1. Which anchor the link points to
  2. The link title (visible in the tooltip when hovering over the link, and used as a caption in the lightbox) (default: 'Statistics')
  3. The "rev" attribute of the link, which holds the options to be passed to floatbox (default: 'scrolling: auto')
  4. The link text (default: 'Statistics')

Example call

Here is an example call, as it would appear in Babe Ruth's page:

{{#sabr-lightbox-link:
 stats_batting
 |Batting statistics for Babe Ruth
 |width:95%;height:95%;scrolling:auto
 |Batting Statistics}}

This call would output this HTML (line breaks added for clarity - real output contains none):

<a 
 href="#stats_batting" 
 title="Batting statistics for Babe Ruth" 
 class="floatbox" 
 rev="width:95%;height:95%;scrolling:auto"
>

Batting Statistics

</a>

This would create the following link, which will do almost nothing on this page: Batting Statistics.

Usage in the Encyclopedia

The extension is written to require options passed to floatbox to be provided as a parameter, rather than hardcoding them. This means that calls directly to the parser function are not pretty and contain information that is not related to encyclopedia content. Therefore, calls should be isolated inside of templates. The parser function is used in the following templates:

Personal tools