Middlebury

Drupal Shortcodes

Revision as of 13:56, 19 September 2014 by Ian McBride (talk | contribs) (List Manager Subscription Forms)

A "shortcode" is a snippet of text that allows you to insert special elements into your page. These can be placed in any WYSIWYG editor window.

Video

The most common shortcode is used to embed video. To embed a video, get its URL from your video service of choice. For MiddMedia use the "HTTP (Download) URL". Here is an example of using the video embed code with a video from MiddMedia of the 2012 Convocation.

[video:http://middmedia.middlebury.edu/media/Communications_LiveRecording-MIDD-web_data-middlebury-edu/mp4/2012Convocation.mp4]

Supported Video Sources

We support video from the following sources.

Video Player Attributes

You can change the appearance or behavior of the video player using attributes added to the shortcode. Not all of these work on videos from every source listed above. They should all work for videos from MiddMedia. The "width", "height" and "ratio" attributes can be used with any video. All of these are optional.

  • Width written as width:123 where "123" is the desired width of the player, in pixels.
  • Height written as height:123 where "123" is the desired height of the player, in pixels.
  • Image written as image:http://url_of_image.jpg puts a "splash" image over the video player, allowing you to highlight a particular frame if you have a separate image of it.
  • Ratio written as ratio:16/9 allows you to set the aspect ratio of the video player. The default value is 16/9.
  • Align written as align:left or align:right to align the video player to one side of the content.
  • Autoplay written as autoplay:1 or autoplay:0 where "1" indicates that the video should play automatically when the page loads (discouraged) and "0" indicated that the video should only play when the user clicks the play button. The default is "0".
  • Autorewind written as autorewind:1 or autorewind:0 where "1" indicates that after the video is done playing, the play bar is moved back to the beginning and "0" indicates that it is left at the end. The default is "0".
  • Loop written as loop:1 or loop:0 where "1" indicates that the video should begin again after it is finished automatically and "0" indicates that it should not. The default value is "0".

A note about ratio: The default value of this attribute is 16/9. If you have a video that you want to play at a very precise pixel dimension, especially for large videos, or because you are using a specific splash image, you can set the ratio to the value of "width/height". Example: width:589 height:374 ratio:589/374.

Here is an example of a video shortcode using all of these attributes:

[video:http://middmedia.middlebury.edu/media/Communications_LiveRecording-MIDD-web_data-middlebury-edu/mp4/2012Convocation.mp4 width:640 height:480 image:http://middmedia.middlebury.edu/media/Communications_LiveRecording-MIDD-web_data-middlebury-edu/splash/2012Convocation.jpg ratio:16/9 align:left autoplay:0 autorewind:0 loop:0]

YouTube Playlists

You can add a YouTube playlist by adding the playlist ID in the video URL. For example:

[video:http://www.youtube.com/watch?v=DaCP2kdYA4A&p=17B9CA1B31A33C5E]

or

[video:http://www.youtube.com/watch?v=DaCP2kdYA4A&list=17B9CA1B31A33C5E]

In these examples, the playlist ID follows the "p=" or "list=" parts of the URL.

Audio

Audio uses the same shortcode as video, which might be confusing, but will work. The only supported source for audio files is MiddMedia. Here is an example of the shortcode to use for an audio file.

[video:http://middmedia.middlebury.edu/media/imcbride/mp3/Tree_Miller.mp3]

Unlike video, you cannot set the height, width or other attributes of the audio player.

Computer Labs

You might want to add information about the labs that visitors to your site use. We can display the number of available machines in each of these labs to give people real-time information about their usage. To do this use the labserver shortcode.

[labserver] will print the total number of available machines in all computer labs.

[labserver 3] will print the total number of available machines in computer lab 3, which is Armstrong 161.

[labserver 65,43] will print the total number of available machines in computer labs 65 (LIB 105) and computer lab 43 (LIB 140) combined.

You can get the ID of the lab to use by clicking on any of the labs on the LabStats site and looking at the URL, which will include a "lab_id" parameter.

Subject Guides

The LIS Librarians maintain subject guides in a system called "SubjectsPlus" to provide research resources to academic departments. If you would like to add one of these guides to your site, you can use the subjectsplus shortcode by including the SubjectsPlus subject code. For example, the URL of the American Studies subject guide is:

http://sp.middlebury.edu/subjects/guide.php?subject=amstud

so the correct shortcode to use to include this guide is:

[subjectsplus amstud]

Student Theses

Some of the senior theses written by students are kept in the college archives and a list of these materials can be easily added to your site. Each thesis is included in one or more categories by department. To include this list, use the following shortcode.

[view:CONTENTdm_Theses==Economics]

And replace "Economics" with the name of your department from the "Academic Department 1" column in the student thesis repository. You can also include more than one department, for example:

[view:CONTENTdm_Theses==Economics,Environmental Studies]

List Manager Subscription Forms

You can embed a sign-up form for your List Manager mailing list in content using this shortcode, where the second part is the name of your mailing list. For example:

[listmanager middnews_general]

You can have a nice printed description for the list, rather than showing the machine name of the list to the user. To do this, add the description of the list separated from its name by a colon.

[listmanager middnews_general:MiddNews]

You can allow the user to subscribe to multiple lists at once using the same form. To do this, separate this lists with commas.

[listmanager middnews_general:MiddNews,artsmail:Arts at Middlebury]