0

And happy 2016 ;-)

I'm actually trying to learn ZF2, and I have some problems that I dont' know how to resolve.

First, you have to know that the project is running under vagrant. I have 2 modules:

  • Admin
  • Application

I have a layout for each module.

In the admin layout module, I have some style and JS file: All this JS and CSS files are in the public folder.

<?= $this
        ->headLink(array('rel' => 'shortcut icon', 'type' => 'image/vnd.microsoft.icon', 'href' => $this->basePath() . '/img/favicon.ico'))
        ->prependStylesheet($this->basePath('bower_components/bootstrap/dist/css/bootstrap.min.css'))
        ->prependStylesheet($this->basePath('bower_components/font-awesome/css/font-awesome.min.css'))
        ->prependStylesheet($this->basePath('bower_components/Ionicons/css/ionicons.min.css'))
        ->prependStylesheet($this->basePath('css/AdminLTE.min.css'))
        ->prependStylesheet($this->basePath('css/skins/skin-blue.min.css'))
; ?>

<?=
    $this->inlineScript()
        ->prependFile($this->basePath('bower_components/jquery/dist/jquery.min.js'))
        ->prependFile($this->basePath('bower_components/bootstrap/dist/js/bootstrap.min.js'))
        ->prependFile($this->basePath('js/app.min.js'))
;?>

For some CSS file, I have errors in the browser:

Resource interpreted as Stylesheet but transferred with MIME type text/html

And for JS, I have problems too:

Bootstrap's JavaScript requires jQuery

I know this JS error, it append when you load boostrap.js before jquery.js. But here, it's not the case!

I don't know if the problem comes from my layout integration of CSS and JS files, or if I forgot something in the controller, or in the configuration. May be it's a problem with vagrant too?

I also have a htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

Please, I need some help because i'm lost ;-)

Thanks for any advice/documentation or else.

  • 1
    Regarding the Js problem, `$this->prependFile` add the requested fiel BEFORE the others you alredy have. To mantain the order you should use `$this->appendFile()` – marcosh Jan 16 '16 at 18:31
  • Thanks for help, but I always have the same error message – user2711783 Jan 16 '16 at 18:51
  • You should update your code from prependFile to appendFile then, as the latter would be expected in your case, and certainly would seem to be giving you the wrong loading order. Did you already look at the output page source? – dualmon Jan 17 '16 at 21:00
  • What is the generated HTML ? What do you get if your try to access you jquery.min.js file directly ? – Clément Prévost Jan 18 '16 at 22:32

0 Answers0