0
votes

I have a zend framework application up and running. I have created a layout. Now I need to include bootstrap css file to my layout.

I tried with 'baseUrl' but it didn't work. I have the css files inside 'public/assets/css'.

I also tried with tutorial in zend framework website. But it didn't work.

They mentioned to use

<?php echo $this->headLink()->appendStylesheet('/assets/css/bootstrap.css') ?>

I added the above line in layout page but it didn't work.

Also for your information when I use this headlink, in console it's showing as

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8010/assets/css/bootstrap.css".

Any help is greatly appreciated. Thanks in advance.

Head Tag:

<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Zend Framework Quickstart Application</title> 
    <link href="/assets/css/bootstrap.css" media="screen" rel="stylesheet" type="text/css"> 
</head>

Extra information: I have a controller 'HomeController' in it I have defined an action

public function homeTwoAction()
    {
        // action body
        $this->_helper->layout->setLayout('layout');

    }

In views -> I have home-two.phtml inside 'scripts/home'.

In layout I have the following code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Bootstrap</title>
<!--    <link rel="stylesheet" href="style/bootstrap.min.css">-->
<!--    <link rel="stylesheet" href="style/customstyle.css">-->
    <!--<link type="text/css" rel="stylesheet" href="/assets/css/customstyle.css">-->
    <?= $this->headLink()->appendStylesheet('/assets/css/customstyle.css') ?>
    <?= $this->headLink()->appendStylesheet('/assets/css/bootstrap.min.css') ?>

</head>
<body>
    <div class="container-fluid">

        <?php echo $this->layout()->content ?>

    </div>
</body>
</html>

I am accessing

http://localhost:8010/home/home-two

HTML content is loaded but css not loading. Thanks.

1
Post the content of the head tag when the page loads. And what server are you using? Apache?Xpleria
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Zend Framework Quickstart Application</title> <link href="/assets/css/bootstrap.css" media="screen" rel="stylesheet" type="text/css"> </head> Netbeans inbuilt serverTest admin
You need to configure your server to serve has files with appropriate mime typeXpleria
Thanks for the response Neil Patrao. Do I need to configure it in Netbeans web server?Test admin
Yes..in NetbeansXpleria

1 Answers

0
votes

Changing Mime type is explained here

  1. Go to Tools -> Options

  2. Then under Miscellaneous tab choose the file type css and make sure the Associated File Type is text/css

Edit

Try opening http://localhost:8010/assets/css/ or http://localhost:8010/assets/ what do you see?