Difference between revisions of "Widgets"

From StatsLab Wiki
Jump to navigation Jump to search
 
Line 40: Line 40:
  
 
To include any of the above stats, set the stat parameter equal to the lowercase version of the stat (e.g. avg=batting average), with the following exceptions:
 
To include any of the above stats, set the stat parameter equal to the lowercase version of the stat (e.g. avg=batting average), with the following exceptions:
 
+
*2B and 3B should be “d” and “t”, respectively
K, BB, R, G, GS, HP, and WAR for pitchers should be preceded with a “p” to differentiate them from the batter stat version (e.g.: k=batting K’s, pk=pitching K’s).  
+
*K, BB, R, G, GS, HP, and WAR for pitchers should be preceded with a “p” to differentiate them from the batter stat version (e.g.: k=batting K’s, pk=pitching K’s).  
Use “s” for SV.  
+
*Use “s” for SV.  
  
 
Optional: topX, league_id, sub_league
 
Optional: topX, league_id, sub_league

Latest revision as of 11:04, 4 October 2017

The widgets functionality of StatsLab allows you to display information about your league on a different part of your website, or even on a different website completely, by inserting a snippet of PHP code on the page that you wish to include it on.

Widgets work by calling a single php script (widget.php), and adding parameters to that script specific to what you want to display.

Overview

Parameters

Note that not all parameters are relevant to all types of widgets.

  • show - Determines what type of widget will be generated
  • league_id - The OOTP internal league ID of the league you want the widget to work for. If you're not sure, you can get this from the URL of your league's home page.
  • sub_league - The OOTP internal ID of the sub league you want the widget to work for. You can also use the league abbreviation.
  • division - The OOTP internal ID of the division you want the widget to work for.
  • topX - For stat leaderboard widgets, the number of players to display.
  • stat - For stat leaderboard widgets, the statistic to display.
  • lastX - For draft update leaderboards, the number of picks recently made to display.
  • nextX - For draft update leaderboards, the number of upcoming picks to display.

Examples

Division Leaders

Required: show=leaders

Optional: league_id; if omitted, the primary league ID for StatsLab will be used.

Example: widget.php?show=leaders&league_id=100

Standings

Required: show=standings, league_id, sub_league, division

Example: widget.php?show=standings&division=1&sub_league=1

Stat Leaderboards

Required: stat

The stat parameter can include any of the following:

  • Batting Stats: AB, H, 2B, 3B, HR, RBI, R, SB, CS, BB, K, SF, SH, IBB, HP, GDP, PA, AVG, OBP, SLG, OPS, wOBA, WAR
  • Pitching Stats: W, L, SV, IP, K, BB, R, ER, G, GS, HP, HA, BF, GB, FB, HRA, BK, GF, QS, CG, SHO, HLD, ERA, WHIP, WAR

To include any of the above stats, set the stat parameter equal to the lowercase version of the stat (e.g. avg=batting average), with the following exceptions:

  • 2B and 3B should be “d” and “t”, respectively
  • K, BB, R, G, GS, HP, and WAR for pitchers should be preceded with a “p” to differentiate them from the batter stat version (e.g.: k=batting K’s, pk=pitching K’s).
  • Use “s” for SV.

Optional: topX, league_id, sub_league

Example: widget.php?stat=h&topX=7&sub_league=NL

Draft Updates

Required: show=draftList, league_id, lastX, nextX

Example: widget.php?show=draftList&league_id=100&lastX=5&nextX=5

Weekly/Monthly Award Winners

Required: show, league_id, sub_league

The show parameter can contain any of the following:

  • potw - Player of the Week
  • botm - Batter of the Month
  • potm - Pitcher of the Month
  • rotm - Rookie of the Month

Example: widget.php?show=potw&league_id=100&sub_league=0


Formatting/CSS

StatsLab widget components have the following classes applied so that you can format them using CSS as you see fit. The best way to do this is to wrap them in another container, such as a DIV in order to uniquely identify them.

The following classes are implemented:

  • wdgT – Applied to <table> tags
  • wdgH – Applied to <tr> tags contained inside <thead> tags.
  • wdgH_l – Applied to tags inside <thead> tags that might require different alignment.
  • wdg1, wdg2 – Applied to alternating <tr> tags
  • wdg1_l, wdg2_l – Applied to alternating rows <td> tags that might require different alignment
  • wdgUL – Applied to <ul> tag in division leaders widget
  • wdgLI – Applied to <li> tags in division leaders widget

Testing

You can test a widget out for functionality prior to inserting it into it's intended web page location simply by accessing StatsLab and changing the web browser URL to the widget URL. This is also a good way to verify any classes you might want to use for formatting via CSS.

Content Management Systems

Joomla

To add widgets in Joomla, you'll need a php module extension. Flexi Custom Code works well and is recommended.

WordPress

To add widgets in WordPress, you'll need to use an iFrame plugin extension.