7

I have included css in view file as below

<link rel="stylesheet" type="text/css" href="<?php echo $this->baseUrl('style/root.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo $this->baseUrl('style/reset.css'); ?>" />

But it is giving this error ->

  <b>Message:</b> Invalid controller specified (style)  </p>

in application.ini, I have used this

resources.frontController.baseUrl = "/zendtest/public"
resources.view[] = "";

How do I solve this issue?

3 Answers 3

14

in any view file (.phtml extension) use something like this for javascript or css:

$this->headScript()->prependFile('/scripts/jquery.min.js');
$this->headScript()->appendFile('/scripts/fg.menu.js');

$this->headLink()->appendStylesheet('/css/form.css');
$this->headLink()->prependStylesheet('/css/jquery_ui_theme/jquery-ui.custom.css');
Sign up to request clarification or add additional context in comments.

2 Comments

But what is the directory structure for .css and .js files? You say /scripts/jquery.min.js but where is this /script directory lives? Which one is correct if I use modules with ZF: Module/views/scripts/js and Module/views/scripts/css? Or Module/views/js and Module/views/css? Thank you.
no, css & js go into /application/public/css and /application/public/js
2

The code bellow worked for me , ( i suppose you have your css file in 'Public/css/bootstrp.css' ) and paste the line in the head of your View.

<link href="<?php echo $this->baseUrl() . '/css/bootstrap.css'; ?>" media="all" rel="stylesheet" type="text/css" />

Comments

1

Take a look at the headLink() view helper, that will do exactly what you are looking for.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.