How to include css file in view

I have included the css 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 he gives this error →

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

in application.ini, I used this

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

How to solve this problem?

+6
source share
3 answers

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'); 
+14
source

The following code worked for me (suppose you have your css file in "Public / css / bootstrp.css") and insert the line at the beginning of your view.

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

+2
source

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

+1
source

Source: https://habr.com/ru/post/913526/


All Articles