Consente di semplificare e aggiornare questo. Il modo più veloce e più semplice per farlo è la seguente ed è aggiornata al v: 2,9
Scarica le 3 cartelle per il bootstrap qui: http://twitter.github.io/bootstrap/getting-started.html
Poi scompattare e spostare:
css/bootstrap.css
css/bootstrap.min.css
css/bootstrap-responsive.css
css/bootstrap-responsive.min.css
-TO-
app/webroot/css/
-THEN MOVE-
js/bootstrap.js
js/bootstrap.min.js
-TO-
app/webroot/js/
-THEN MOVE-
img/glyphicons-halflings-white.png
img/glyphicons-halflings.png
-TO-
app/webroot/img/
*** È MOLTO IMPORTANTE CHE NON METTERETE QUESTI FILES NELLA RADICE DEL VOSTRO SITO (ve lo spiegherò dopo ...) !!!
Poi, nell'editor del codice di vostra scelta (io preferisco Netbeans) aprire il file:
app/View/Layouts/default.ctp
Esso dovrebbe essere simile:
<?php
/**
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package app.View.Layouts
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
$cakeDescription = __d('cake_dev', 'CakePHP: the rapid development php framework');
?>
<!DOCTYPE html>
<html>
<head>
<?php echo $this->Html->charset(); ?>
<title>
<?php echo $cakeDescription ?>:
<?php echo $title_for_layout; ?>
</title>
<?php
echo $this->Html->meta('icon');
echo $this->Html->css('cake.generic');
echo $this->fetch('meta');
echo $this->fetch('css');
echo $this->fetch('script');
?>
</head>
<body>
<div id="container">
<div id="header">
<h1><?php echo $this->Html->link($cakeDescription, 'http://cakephp.org'); ?></h1>
</div>
<div id="content">
<?php echo $this->Session->flash(); ?>
<?php echo $this->fetch('content'); ?>
</div>
<div id="footer">
<?php echo $this->Html->link(
$this->Html->image('cake.power.gif', array('alt' => $cakeDescription, 'border' => '0')),
'http://www.cakephp.org/',
array('target' => '_blank', 'escape' => false)
);
?>
</div>
</div>
<?php echo $this->element('sql_dump'); ?>
</body>
</html>
Trovare questa:
echo $this->Html->css('cake.generic');
Sotto aggiungere questo:
echo $this->Html->css('cake.generic');
echo $this->Html->css('bootstrap');
echo $this->Html->css('bootstrap.min');
echo $this->Html->css('bootstrap-responsive');
echo $this->Html->css('bootstrap-responsive.min');
Trovare questa:
echo $this->fetch('script');
Sotto di esso aggiungere questo:
echo $this->Html->script('bootstrap');
echo $this->Html->script('bootstrap.min');
*** Ricordate prima, quando ho detto che stavo per spiegare perché i file devono essere nella directory webroot (per qualcuno nuovo di MVC)? Il codice sopra è come Cake include i suoi script e css. Il metodo che usa per questo aspetto in app/webroot/js per i file javascript; e rispettivamente in app/webroot/css per i file css.Questo fa sì che i file js e css siano sincronizzati. Se vuoi includere i file js/css GLOBALLY loro default.ctp.
* Se è necessario solo uno script da utilizzare con una vista/pagina, utilizzare lo stesso codice sul file di visualizzazione su cui è necessario.
Potrebbe sembrare un po 'complicato ma dovrebbe richiedere solo 3 minuti per includere globalmente il bootstrap di Twitter in questo modo.
Spero che questo aiuti!
Grazie! Questo e 'esattamente quello che stavo cercando! – skimberk1
Prego. Ho visto il tuo post la scorsa settimana mentre cercavo la soluzione da solo. –
@Jamie grazie per la risposta! Molto apprezzato :-) Stavo girovagando se è possibile integrare nel controllo div quando viene attivato un errore di convalida? Sembra meglio dell'avviso IMO. – Sid