Four Methods for loading Bootstrap or other components for module separately in yii

Source: Internet
Author: User

Bootstrap contains a wide range of web components. Based on these components, you can quickly build a beautiful and fully functional website.
But sometimes we do not need Bootstrap at the front end of our website. As long as Bootstrap is used in the management background, how can we load Bootstrap for a module separately?

Here are 4 methods to implement this:
1. Add the following content (protected/config/Main. php) to the application configuration file ):

'Modules' => array ('admin' => array ('preload' => array ('<SPAN class = 'wp _ keywordlink_affiliate'> <a href = "http://lxy.me/tag/bootstrap" title = "view all articles in Bootstrap" target = "_ blank"> Bootstrap </a> </span> '), 'components' => array ('<SPAN class = 'wp _ keywordlink_affiliate'> <a href = "http://lxy.me/tag/bootstrap" Title = "view all articles in Bootstrap" target = "_ blank"> Bootstrap </a> </span> '=> array ('class' => 'ext. bootstrap. components. bootstrap ')),//... other modules ...)

2. Load During module initialization:

    public function init()    {        // import the module-level models and components        $this->setImport(array(            ‘admin.models.*‘,            ‘admin.components.*‘,            // ‘ext.bootstrap.components.Bootstrap‘, // this will go to app config for components        ));        Yii::app()->getComponent(‘bootstrap‘);// this does the loading    }

3. Another method for initialization and loading of modules:

    public function init()    {        // import the module-level models and components        $this->setImport(array(            ‘admin.models.*‘,            ‘admin.components.*‘,        ));        $this->configure(array(                ‘components‘=>array(                    ‘bootstrap‘=>array(                        ‘class‘=>‘ext.bootstrap.components.Bootstrap‘                    )                )        ));        $this->getComponent(‘bootstrap‘);    }

4. Another method for Loading modules:

    public function init()    {        // import the module-level models and components        $this->setImport(array(            ‘admin.models.*‘,            ‘admin.components.*‘,        ));        $this->configure(array(                ‘preload‘=>array(‘bootstrap‘),                ‘components‘=>array(                    ‘bootstrap‘=>array(                        ‘class‘=>‘ext.bootstrap.components.Bootstrap‘                    )                )        ));        $this->preloadComponents();    }


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.