Navdeep
Navdeep

Reputation: 335

how to include css in view file

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?

Upvotes: 7

Views: 10805

Answers (3)

timmz
timmz

Reputation: 2252

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" />

Upvotes: 2

max4ever
max4ever

Reputation: 12142

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');

Upvotes: 14

vascowhite
vascowhite

Reputation: 18440

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

Upvotes: 1

Related Questions