cakephp how can i include bootstrap framework css style to my app?

前端 未结 2 1485
别跟我提以往
别跟我提以往 2021-01-26 16:32

Anybody has integrated cake php with bootstrap framework/css style ?

I want to be able use advantages of bootstrap in cakephp views : like btn\'s and panels bootstrap s

相关标签:
2条回答
  • 2021-01-26 16:54

    Download bootstrap css and js files and put them in webroot/css or webroot/js respectively.

    Then in app/View/Elements/header.ctp file add

    <link rel="stylesheet" href="<?php echo Router::url('/css/bootstrap.min.css', true); ?>">
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    

    And in app/View/Elements/footer.ctp add

    <script type="text/javascript" src="<?php echo Router::url('/js/bootstrap.min.js', true); ?>"></script>
    

    Now you can access bootstrap classes in your code.

    0 讨论(0)
  • 2021-01-26 17:18

    If you want to use downloaded bootstrap library. Just put your bootstrap.min.css file inside /app/webroot/css/ folder.

       app/
          webroot/
                 css/ <-- here
    

    and then use it like below using HtmlHelper

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

    OR

    If you want to use cdn the just add the below code inside head tag of .ctp file

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    

    Cakephp 2.x -> HtmlHelper

    Hope this will help!

    0 讨论(0)
提交回复
热议问题