SibinF
SibinF

Reputation: 385

Integrating Bootstrap Template into cakephp

There are lots of peoples asked about integrating twitter bootstrap with cakephp. i followed lots of tutorial but nothing was helped me. I downloaded one bootstrap template for my admin panel. but i dont know how to integrate it with cakephp. i have used templates before, and i copied the css and js into

     app/webroot/css 
     app/webroot/js

and it works fine,but when i open this templates there are many folders inside it

     asset
     bootstrap
     venders,and some html pages

i don't know how to integrate it in cakephp. if anybody knows please give me a step by step procedure so that it helps all people.. Thanks

Upvotes: 3

Views: 6802

Answers (1)

Sainesh Mamgain
Sainesh Mamgain

Reputation: 785

Integrating a bootstrap template in cakephp is very easy.

First copy all your css in app/webroot/css/.

Second copy all js in app/webroot/js/.

Third copy all fonts (like fontawesome) in app/webroot/fonts/ (you will have to create this directory).

Fourth from the template cut the code from <html> to </head> and paste in a new file header.ctp under folder app/view/elements/.

Fifth create a file mylayout.ctp in folder app/view/layout/ write the following code in it

<?php
    echo $this->element('header');
    echo $this->fetch('content');
?>

sixth in your controller say UsersController.php create a function index.

<?php
    class UsersController extends AppController{
        public function index(){
             $this->layout='mylayout';
        }
    }
?>

Seventh in your header.ctp delete all <link> to css and instead of write

<?php echo $this->Html->css(array('ccs1','css2','css3'));?>

do the same with all the scripts

<?php echo $this->Html->script(array('script1','script2','script3'));?>

Now, create a new file index.ctp in the app/view/Users/ folder. You will have to create this folder.

In the index.ctp copy all the remaining code from the template file starting from <body> tag to </html> tag.

At last in your browser open localhost/pathToYourProject/Users/

You can also create a footer element if you want.

This is a basic example to integrate any template in cakephp.

Upvotes: 3

Related Questions