2

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

7 Answers 7

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

thanks @ ohm but i guess that is the same solution @nav has provided
3

Everything in application directory is not accessible via your web server you would either have to move the file to the public directory or setup a symlink to it.

Comments

1

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.

1 Comment

Just what I needed, thanks! Not sure why this isn't accepted as answer.
0

You should use this code:

<link rel="stylesheet" type="text/css" media="screen" href="<?=$this->baseUrl();?>/yourpathtocss" />

Comments

0

I think the correct way is to do this from layout.phtml as follows

<?php echo $this->headLink()->appendStylesheet('/css/site.css') ?>

Comments

0

here 'TestZend' is Project name

<?php echo $this->headLink()->appendStylesheet('/TestZend/public/css/bootstrap.css'); ?>

Comments

0

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>

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.