Yii 1.1: scriptset

Register 'sets' of CSS and Javascript Per Controller Action and Manage From A Single Location
1 follower

This extension is a very, very simple implementation of the CakePHP component 'Asset Manager'. You define sets of CSS and Javascript, then tell your controller actions to load whatever set is needed for that view.

This extension does not combine or compress any files, but works fine with the excellent 'extendedclientscript' that this extension is intended to complement (but not required).

Documentation

Requirements

  • Yii 1.0 or above

Installation

  • Extract the release file under protected/components

Usage

It's super simple and almost not worth posting =)

First, define some sets within the release file itself:

    /*
     * Define the CSS sets below
     */
    private $cssSets = array (
        'groovy' => array (
            '/css/some.css',
            '/css/another.css',
            '/css/ie_hacks_boo.css'
        ),  

        'setName2' => array (
            '/css/some.css',
            '/css/another.css',
            '/css/common.css',
            '/css/style.css'
        ),      
    );

    /*
     * Define the Javascript sets below
     */ 
    private $jsSets = array (
        'beans' => array (
        ),

        'setName2' => array (
            '/js/jquery/jquery.js',
            '/js/uber.js',
            '/js/obtrusive.js',
            '/js/ruby_port.js'
        ),
    );  

then, in a controller action, load whatever CSS and JS sets you need for that view (the first argument is the CSS set, the second is the JS set):

      $scriptSet = new ScriptSet;
      $scriptSet->loadSet('groovy', 'beans');

Change Log

April 21, 2009

  • Initial release.

Be the first person to leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: drech
  • Category: Caching
  • Votes: No votes yet
  • Downloaded: 483 times
  • Created on: Apr 22, 2009
  • Last updated: never