slywalker/twitter_bootstrap

CakePHP Bootstrap (Twitter版) 插件

安装量: 31,554

依赖: 0

建议者: 0

安全性: 0

星级: 287

关注者: 32

分支: 92

开放问题: 2

类型:cakephp-plugin

1.5.7 2013-09-05 03:38 UTC

This package is not auto-updated.

Last update: 2024-09-14 13:18:06 UTC


README

此插件的开发已转移到 BoostCake.

##CakePHP2.x版本的TwitterBootstrap插件 The TwitterBootstrap Plugin提供了一个易于使用的Bootstrap功能,适用于CakePHP2.x

来自Twitter的Bootstrap

此v1.5.7支持Bootstrap v2.2.2

##安装 ###本插件

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"
  }
}

子模块

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

克隆

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

###启用插件 您需要在app/Config/bootstrap.php文件中启用该插件

CakePlugin::load('TwitterBootstrap');

如果您已经使用了CakePlugin::loadAll();,则此步骤不是必须的。

###bootstrap手册

  • 下载bootstrap: 来自Twitter的Bootstrap
  • 解压下载文件。
  • 将生成的文件夹中的(css, img, js)文件夹复制到app/webroot

Shell命令(需要recessuglifyjs

(将less, js, img文件复制到webroot并生成css, js文件)

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

##使用 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'),
	);

}

视图/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'); ?>

以Bootstrap格式输出表单输入

<?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(); ?>

以Bootstrap格式输出SessionHelper::flash

// 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'),
)); ?>

以Bootstrap格式输出分页

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

面包屑导航

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

您可以查看更多示例。访问 http://{webroot}/twitter_bootstrap

##许可证

MIT许可证 (MIT)

版权所有 (c) 2012 Yasuo Harada

特此授予任何获得本软件及其相关文档(“软件”)副本的个人免费使用权,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,并允许软件提供者进行此类操作,但需遵守以下条件

上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。

软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、特定用途适用性和非侵权性保证。在任何情况下,作者或版权所有者均不对因软件的使用、侵权或其他行为而产生的任何索赔、损害或其他责任负责。