Reputation: 4031
I'm trying to add a css file in my zend application layout.php
the problem is it resides in
/application/media/css/style.css
when i do
<?php echo $this->headLink()->appendStylesheet('/media/css/style.css') ?>
it generates the path like
appname/public/media/css/style.css
where as i need to generate the path like
appname/application/media/css/style.css
how can i tell zend to look for the css file at a apecific location in layout.php
Upvotes: 2
Views: 9288
Reputation: 1
Just add this code snippet in the layout section to make sure the MEDIA folder is created inside yourProjectFoder/public/media/css/style.css
<head>
// some code here...
<?= $this->headLink()
//added from the new template
->prependStylesheet($this->basePath('media/css/style.css'))
?>
// some other code here
</head>
Upvotes: 0
Reputation: 334
Just to complete all the answers, is not "correct" put your CSS, JS, fonts, and all other media in 'application' folder. The 'public' folder is there for that. Then, to remove the '/public' from all your URLs, just make a simple change in your .htaccess
RewriteEngine On
RewriteBase / # you could put some subfolder, if you need
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
And in your index.php
<?php
define('RUNNING_FROM_ROOT', true);
include 'public/index.php';
And then you could use this to append your styles
<?php echo $this->headLink()->appendStylesheet('/public/media/css/style.css') ?>
Hope it helps.
Upvotes: 1
Reputation: 1
here 'TestZend' is Project name
<?php echo $this->headLink()->appendStylesheet('/TestZend/public/css/bootstrap.css'); ?>
Upvotes: 0
Reputation: 1
I think the correct way is to do this from layout.phtml as follows
<?php echo $this->headLink()->appendStylesheet('/css/site.css') ?>
Upvotes: 0
Reputation: 186
You should use this code:
<link rel="stylesheet" type="text/css" media="screen" href="<?=$this->baseUrl();?>/yourpathtocss" />
Upvotes: 0
Reputation: 140
I have solved the problem. Always is simple. :D I added
<link rel="stylesheet" href="css/site.css" type="text/css" media="screen, projection">
in head tag. And css folder is in public folder.
thanks ohm
Upvotes: 4