• Stars
    star
    287
  • Rank 144,232 (Top 3 %)
  • Language
    PHP
  • Created about 13 years ago
  • Updated about 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Plugin for CakePHP2 to use Bootstrap, from Twitter (CSS JS Framework)

#Development of this plugin has moved BoostCake.

#TwitterBootstrap Plugin for CakePHP2.x The TwitterBootstrap Plugin provides an easy-to-use feature Bootstrap in CakePHP2.x

Bootstrap, from Twitter

This v1.5.7 supports Bootstrap v2.2.2

##Installation ###This plugin

Composer

{
  "repositories": [
    {
      "type": "package",
      "package": {
        "name": "twitter/bootstrap",
        "version": "dev-master",
        "source": {
          "url": "git://github.com/twitter/bootstrap",
          "type": "git",
          "reference": "master"
        },
        "require": {
          "composer/installers": "*"
        }
      },
      "packagist": false
    }
  ],
  "require": {
    "twitter/bootstrap": "dev-master",
    "slywalker/twitter_bootstrap": "dev-master"
  },
  "config": {
    "vendor-dir": "Vendor"
  }
}

Submodule

$ cd /your_app_path
$ git submodule add git://github.com/slywalker/TwitterBootstrap.git Plugin/TwitterBootstrap
$ git submodule update --init --recursive

Clone

$ cd /your_app_path/Plugin
$ git clone git://github.com/slywalker/TwitterBootstrap.git
$ cd TwitterBootstrap
$ git submodule update --init

###Enable plugin You need to enable the plugin your app/Config/bootstrap.php file:

CakePlugin::load('TwitterBootstrap');

If you are already using CakePlugin::loadAll();, then this is not necessary.

###bootstrap Manual

  • Download bootstrap: Bootstrap, from Twitter
  • Unzip that download.
  • Copy folders(css, img, js) in the resulting folder to app/webroot

Shell Command (need recess and uglifyjs)

(Copy less, js, img files to webroot and make css, js files)

$ cd /your_app
$ Console/cake TwitterBootstrap.copy
$ Console/cake TwitterBootstrap.make

##Usage Controller/AppController.php:

<?php
class AppController extends Controller {

	public $helpers = array(
		'Session',
		'Html' => array('className' => 'TwitterBootstrap.BootstrapHtml'),
		'Form' => array('className' => 'TwitterBootstrap.BootstrapForm'),
		'Paginator' => array('className' => 'TwitterBootstrap.BootstrapPaginator'),
	);

}

View/Layout/default.ctp:

<?php echo $this->Html->css('bootstrap.min'); ?>
<?php echo $this->Html->css('bootstrap-responsive.min'); ?>
<?php echo $this->Html->script('bootstrap.min'); ?>

Output form input as Bootstrap format

<?php echo $this->Form->create('Sample', array('class' => 'form-horizontal')); ?>
	<fieldset>
		<legend>Extending form controls</legend>
		<?php echo $this->Form->input('field1', array(
			'label' => 'Prepended text',
			'type' => 'text',
			'class' => 'span2',
			'prepend' => '@',
			'helpBlock' => 'Here\'s some help text',
		)); ?>
		<?php echo $this->Form->input('field2', array(
			'label' => 'Appended text',
			'type' => 'text',
			'class' => 'span2',
			'append' => '.00',
			'helpInline' => 'Here\'s more help text',
		)); ?>
		<?php echo $this->Form->input('field3', array(
			'label' => 'Append and prepend',
			'type' => 'text',
			'class' => 'span2',
			'prepend' => '$',
			'append' => '.00',
		)); ?>
		<?php echo $this->Form->input('field4', array(
			'label' => 'Append with button',
			'type' => 'text',
			'class' => 'span2',
			'append' => array('Go!', array('wrap' => 'button', 'class' => 'btn')),
		)); ?>
		<?php echo $this->Form->input('field5', array(
			'label' => 'Inline checkboxes',
			'type' => 'select',
			'multiple' => 'checkbox inline',
			'options' => array('1', '2', '3'),
		)); ?>
		<?php echo $this->Form->input('field6', array(
			'label' => 'Checkboxes',
			'type' => 'select',
			'multiple' => 'checkbox',
			'options' => array(
				'1' => 'Option one is this and that¡ªbe sure to include why it\'s great',
				'2' => 'Option two can also be checked and included in form results',
				'3' => 'Option three can¡ªyes, you guessed it¡ªalso be checked and included in form results',
			),
			'helpBlock' => '<strong>Note:</strong> Labels surround all the options for much larger click areas and a more usable form.',
		)); ?>
		<?php echo $this->Form->input('field7', array(
			'label' => 'Radio buttons',
			'type' => 'radio',
			'options' => array(
				'1' => 'Option one is this and that¡ªbe sure to include why it\'s great',
				'2' => 'Option two can is something else and selecting it will deselect option one',
			),
		)); ?>
		<div class="form-actions">
			<?php echo $this->Form->submit('Save changes', array(
				'div' => false,
				'class' => 'btn btn-primary',
			)); ?>
			<button class="btn">Cancel</button>
		</div>
	</fieldset>
<?php echo $this->Form->end(); ?>

Output SessionHelper::flash as Bootstrap format

// SomethingsController
$this->Session->setFlash(__('The something has been saved'), 'alert', array(
	'plugin' => 'TwitterBootstrap',
	'class' => 'alert-success'
));
$this->Session->setFlash(__('The something could not be saved. Please, try again.'), 'alert', array(
	'plugin' => 'TwitterBootstrap',
	'class' => 'alert-error'
));

// View
<?php echo $this->Session->flash(); ?>

// Auth
<?php echo $this->Session->flash('auth', array(
	'element' => 'alert',
	'params' => array('plugin' => 'TwitterBootstrap'),
)); ?>

Output Paginate as Bootstrap format

// div.pagination.pagination-centered
<?php echo $this->Paginator->pagination(); ?>
// ul.pager
<?php echo $this->Paginator->pager(); ?>

Breadcrumb

<?php echo $this->Html->breadcrumb(array(
	$this->Html->link('one', '/one'),
	$this->Html->link('two', '/two'),
	'three',
)); ?>

You can see more sample. access http://{webroot}/twitter_bootstrap

##License

The MIT License (MIT)

Copyright (c) 2012 Yasuo Harada

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

cakephp-plugin-boost_cake

Bootstrap Plugin for CakePHP
PHP
279
star
2

account_manager

CakePHP AccountManager Plugin
PHP
16
star
3

pdf

CakePHP PDF Plugin
PHP
16
star
4

give_me_data

Insert fake data plugin for CakePHP
PHP
11
star
5

mobile_kit

CakePHP Mobile Plugin
PHP
10
star
6

cakephp-plugin-mysql_util

MySQL Util Plugin for CakePHP2
PHP
9
star
7

vendors

slywalker's vendors for CakePHP
PHP
7
star
8

CakeEmailPlus

CakePHP2.x email extensions
PHP
5
star
9

CakeSublimeText2

CakePHP2.x completions
PHP
5
star
10

jquery

CakePHP Jquery Plugin
PHP
5
star
11

tool_kit

CakePHP Tool Plugin
PHP
4
star
12

CakePlugins

My favorite CakePHP2.x plugins
4
star
13

CakePHPWorkshopKansai

CakePHP Workshop Kansai Sample Code
PHP
4
star
14

form_mail

CakePHP FormMail Plugin
PHP
4
star
15

cakephp-plugin-base

PHP
3
star
16

cakephp-my-startup

PHP
2
star
17

cakephp-plugin-debug_kit_plus

Add Panel in DebugKit
PHP
2
star
18

bingo

ビンゴくじ
2
star
19

TextMateBundles

My TextMate Bundles
2
star
20

chef_php_on_nginx_quick_start

Chef PHP on Nginx Quick Start
Ruby
2
star
21

cakephp-app-api_sample

PHP
2
star
22

image_kit

CakePHP Image Plugin
PHP
2
star
23

study_collect

PHP
2
star
24

slywalker.github.com

slywalker's Github Repositories
1
star
25

custom_validate

CakePHP Custom Validate and I18n Validate Message Plugin
PHP
1
star
26

openpne_message

OpenPNEのメッセージを監視するため一覧を表示するだけのもの CakePHP1.3
PHP
1
star
27

vagrant-cloudera-cdh-pseudo

Vagrant Cloudera CDH Pseudo
Shell
1
star
28

cakephp-plugin-micro_data

CakePHP Plugin - create table of schema MicroData format http://schema.org
PHP
1
star
29

demo20110827

demo20110827
PHP
1
star
30

sandbox

sandbox
1
star
31

madeleine

Mail Magazine Project Cake1.2.x
PHP
1
star