Relative Paths Within CSS And Assets Manager

Hello there,

I’m currently writing a widget that needs to publish a CSS file and some images (icons and separators). All these files are stored in an “assets” directory within my widget’s directory.

+myWidget

myWidget.php

++assets

+++images

    image1


    image2

+++css

    style.css

Publishing is achieved with a level 1 argument in order to get the css and images folder :


Yii::app()->getAssetManager()->publish($this->assets, false, 1);

So far so good, a directory is created under the assets public directory, containing two subfolders (css and images).

The style.css file is correctly loaded, thanks to


registerCssFile()

Now my problem is that this css file calls images as background and I can’t get it working.

I’ve tried some directory traversal :


url("../images/image1")

but it is not processed correctly so I get a


url-to-css-directory/../images/image1

Does any of you could tell me if what I’m intending to do is standard and if the problem comes from Yii or any other software component on my server ?

One obvious solution would be to forget about segmenting my widget’s assets, which I will end up doing if nothing else can be done. I guess I’m just curious…

Thank you so much :)

e: sry, I misunderstood the question. It should actually be possible to do want you want to do. Have you tried the css url without the quotation marks?

This is relevant to my interests. Has somebody found a solution for this?

What comes to my mind is to register CSS directly in the view where you can use the path generated by the asset manager. But that seems awkward.