1

i have the fallowing structure

/app
    application/
        configs/
        modules/
             default/
                   controllers/
                   layouts/
                   views/
                   forms/
             profile/
                   controllers/
                   layouts/
                   views/
                   forms/
                   assets/
                       css/
                       js/
                       images/
    library/
    public/
        css/
        js/
        images/
        uploads/

how can i load js and css files from

/application/modules/profile/assets/...?

and use something similar with

$this->view->headLink()->appendStylesheet('path/to/file');

any ideas on this issue?

2 Answers 2

1

The HeadLink view helper only manages the references to CSS files which are rendered in the section of your HTML page. These stylesheets should have always have a public URL, which means that they'll have to reside somewhere in the 'public' folder.

One solution would be to just move the CSS files there. Another solution would be tohave some kind of PHP script which reads the CSS files from the location outside the 'public' folder and then prints the content of it. Zend Framework does not have a standard component for this though, so I would recommend to reorganise the project, so all the CSS can reside somewhere in the 'public' folder.

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

Comments

1

Although, I agree with P44T that the style sheets should always be kept inside of the public folder there are some cases where you might need to add some additional styling from your module as you do. One example of doing so is if you want to distribute your module separate from the application and you don't want to add the style sheet separately from adding the module.

Here is one example of how you could that from any view:

<?php $this->headStyle()->captureStart() ?>
    // add plain css or include a file like this:
    <?php include APPLICATION_PATH . 'modules/[modulename]/assets/css/style.css'; ?>
<?php $this->headStyle()->captureEnd() ?>

Hope this helps :)

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.