Jamroom Logo Jamroom 5 Core
is now Open Source!
Follow Jamroom on Twitter!

{jr_html_select} Index {jr_lang_prepare}

{jr_javascript_src}


The {jr_javascript_src} template function is used to create a URL that points to the proper cached version of a set of Javascript files that have been processed by Jamroom's Javascript handler.

Parameters:

Name Type Required Default Description
mode string no "skin"

The "mode" parameter tells Jamroom what directory to look in for the js.php control file (config).  Default is "skin", which means Jamroom will look in the jamroom/skins/Active_Skin directory for the config file to process.  Valid options are:

  • "skin"
  • "theme"
  • "cp"
skin string no n/a If you are using the "skin" or "cp" mode, then you can also define the Skin Name by using the "skin" parameter - this allows you to tell Jamroom to look into a specific skin directory for the required js.php file.
theme string no n/a If you are using the "theme" mode, then you need to also pass in the theme directory (i.e. "Sage") as the theme parameter, so Jamroom knows that theme directory to look in for the required js.php file.
config string no "js.php" If you would like to define an alternate name for the required js.php file, you can pass the new name in with the "config" parameter.

 

Example Usage:

<script type="text/javascript" language="javascript" src="{jr_javascript_src skin="Nova"}"></script>

<script type="text/javascript" language="javascript" src="{jr_javascript_src mode="theme" theme="Nova" config="js2.php"}"></script>

 

Required js.php file:

The {jr_javascript_src} function "reads" a required config file, that is (by default) called "js.php" and must be located in the skin, theme, or skin/cp directory.  It defines a PHP "array" of Javascript files that Jamroom will process and "include" in the single cached output file:

<?php
// js.php - Nova Skin Javascript definitions
// @package Jamroom_Library
// @copyright 2003-2010 by Brian Johnson / Talldude Networks LLC
// @author Brian Johnson - bigguy@talldude.net
// $Id: js.php,v 1.2 2010/05/19 18:42:02 bigguy Exp $
defined('IN_JAMROOM') or exit();

// Full path to Javascript => minify/no_minify/code
$_javascript["{$jamroom['jm_dir']}/include/js/jquery.form.js"] = 'minify';
$_javascript["{$jamroom['jm_dir']}/include/js/swfobject.js"] = 'no_minify';
$_javascript["{$jamroom['jm_dir']}/skins/Nova/js/jquery.corners.js"] = 'minify';
$_javascript["{$jamroom['jm_dir']}/skins/Nova/js/jquery.nova.js"] = 'minify';
 

Each line in the js.php file consists of: "full path to Javscript file" = "whether or not to minify the file" so for example:

$_javascript["{$jamroom['jm_dir']}/include/js/jquery.form.js"] = 'minify';

This would cause Jamroom to include the {$jamroom['jm_dir']}/include/js/jquery.form.js Javascript file, and "minify" it before caching it. "Minification" uses the excellent "JSMin" library, and results in much smaller javascript output files. If the Javascript library you are using is already minimized, then make sure and us "no_minify" as the option.


{jr_html_select} page 128 of 171 {jr_lang_prepare}
Solutions Products Support Community Company
Social Media Platform
Social Networking Software
Musician Website Manager
Community Builder
Jamroom 5
Jamroom 5 Modules
Jamroom Marketplace
Support Forum
Documentation
Support Center
Contact Support
Community Forum
Member Sites
Developers
About Us
Contact Us
Privacy Policy
©2003 - 2024 The Jamroom Network