QCubed wrappers for Twitter Bootstrap. Specifically for QCubed v4 and above.
QCubed plugin to simplify the integration of Twitter Bootstrap, (*1)
1) Install both the plugin and twitter bootstrap using Composer. Execute the following on the command line from your main install directory:, (*2)
composer require qcubed/bootstrap composer require twbs/bootstrap
2) Next, you might want to alter some of the settings in the bootstrap.cfg.php file. Look for that in /project/includes/configuration/active, (*3)
The default setting for this file is:, (*4)
define ('QCUBED_BOOTSTRAP_CSS', QCUBED_VENDOR_URL . '/twbs/bootstrap/dist/css/bootstrap.min.css');
If you are compiling your own custom version of the bootstrap css file, simply set that define to point to your own version., (*5)
3) Point the base class to Bootstrap classes so that they add their functionality., (*6)
In your project/qcubed/Control/ControlBase.php file, extend from the Bootstrap Control class. For example, you should change the first line to:, (*7)
abstract class ControlBase extends QCubed\Bootstrap\Control {
The default mechanism included in this plugin only loads the bootstrap.js file on forms using the plugin widgets that need it. If you are hand-coding some bootstrap forms that also need bootstrap.js, you should do both of the following to avoid multiple bootstrap.js files being loaded:, (*8)
1) Define QCUBED_BOOTSTRAP_JS in your bootstrap.cfg.php file and point it to your desired bootstrap js file as so:, (*9)
define ('QCUBED_BOOTSTRAP_JS', QCUBED_VENDOR_URL . '/twbs/bootstrap/dist/js/bootstrap.js'); (or bootstrap.min.js if you prefer)
2) Either add this file to your footer.inc.php file like this:, (*10)
<script type="text/javascript" src="<?= QCUBED_BOOTSTRAP_JS ?>"></script>
or add it to the list of auto-loaded javascript forms in your QForm.class.php file like this:, (*11)
protected function getFormJavaScripts() { $scripts = parent::getFormJavaScripts(); $scripts[] = QCUBED_BOOTSTRAP_JS; return $scripts; }
See the examples pages for details. The main functionality includes:, (*12)
Using RenderFormGroup instead of RenderWithName to draw form objects in the Bootstrap way. The Bootstrap Control class exposes a number of utility classes to add Bootstrap class to the object, the label, the wrapper, and even some internal wrappers in special situations., (*13)
Specific Bootstrap type Controls to draw particular things on the screen. Examples include:, (*14)
Extensions of base QCubed controls with additional Bootstrap functionality. Includes:, (*15)
Defines that give you easy access to all the various Bootstrap class names via PHP constants. Those are located in the Bootstrap.php file., (*16)