4 ways to load bootstrap or other components separately for module in Yii _php tutorial

Source: Internet
Author: User
The bootstrap contains a rich set of Web Components that allow you to quickly build a beautiful, fully functional website. But sometimes our site front desk does not need bootstrap, as long as the management background using bootstrap, then how to separate for a module loading bootstrap?

Here are 4 ways to accomplish this:
1. Add the following (protected/config/main.php) to the application's configuration file:

Php

The code is as follows Copy Code
' Modules ' =>array (
' Admin ' =>array (
' Preload ' =>array ('bootstrap'),
' Components ' =>array (
'bootstrap' =>array (
' Class ' = ' Ext.bootstrap.components.Bootstrap '
)
),
// ... Other modules ...
)

2. Load on module initialization:

The code is as follows Copy Code
Public Function init ()
{
Import the Module-level models and components
$this->setimport (Array (
' Admin.models.* ',
' Admin.components.* ',
' Ext.bootstrap.components.Bootstrap ',//This'll go to app config for components
));
Yii::app ()->getcomponent (' Bootstrap ');//This does the loading
}


3. Another method of module initialization loading:

The code is as follows Copy Code

Php
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 way to load the module:

The code is as follows Copy Code

Php
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 ();
}

http://www.bkjia.com/PHPjc/631525.html www.bkjia.com true http://www.bkjia.com/PHPjc/631525.html techarticle The bootstrap contains a rich set of Web Components that allow you to quickly build a beautiful, fully functional website. But sometimes our website front desk does not need bootstrap, only ...

  • Related Article

    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.