Queuing Assets

The Fuse CMS Framework comes with several JavaScript asset libraries. To use these assets you need to set them as dependencies when you register your JavaScript function files, and also set them as dependencies for your themes stylesheet (see above for information).

A full example looks like this.

<?php
    /** * Set up our theme. */
    namespace Fuse\Theme\Demo;

    class Setup { 

        /**
         * Object constructor.
         */
        public function __construct () {
            global $fuse;

            /**
             * JavaScript files.
             */
            $fuse->template->javascript->register (new \Fuse\Queue\Item\JavaScript ('sn_theme_website_functions', FUSE_THEME_DEMO_BASE_URL.'/javascript/functions.js', array ('jquery', 'superfish', 'colorbox')));
            $fuse->template->javascript->queue ('sn_theme_website_functions');

            /**
             *  CSS files
             */
            $fuse->template->css->register (new \Fuse\Queue\Item\CSS ('sn_theme_website_fonts', FUSE_THEME_DEMO_BASE_URL.'/css/fonts.css'));
            $fuse->template->css->register (new \Fuse\Queue\Item\CSS ('sn_theme_website_editor', FUSE_THEME_DEMO_BASE_URL.'/css/editor.css'));
            $fuse->template->css->queue ('sn_theme_website_fonts', 'editor');
            $fuse->template->css->queue ('sn_theme_website_editor', 'editor');

            add_filter ('fuse_css_fuse_theme_style_dependencies', array ($this, 'stylesheetDependencies'));
        } // __construct ()

        /**
         *  Add our stylesheet dependencies.
         */
        public function stylesheetDependencies ($deps) {
            $deps [] = 'superfish';
            $deps [] = 'colorbox';

            return $deps;
        } // stylesheetDependencies ()

    } // class Setup