eZ Community » Forums » Extensions » ezjscore with css and images on...
expandshrink

ezjscore with css and images on separate host?

ezjscore with css and images on separate host?

Wednesday 09 June 2010 4:14:37 am - 14 replies

On one site I have to have static images and CSS on a separate hosts (for example images.myhost.com and css.myhost.com). So I would like to use ezjscore extension and the ezcss() template operator to generate the CSS files with the correct URLs to images. But I want this URLs to be full absolute URLs, with hostname, for example:

{ background: url(http://images.myhost.com/design/mysite/images/bottom.gif)}

Can this be done with the ezcss() operator and how?

Tuesday 15 June 2010 1:54:28 pm

Anyone knows the answer?

Tuesday 15 June 2010 2:07:52 pm

Hi Marko,

While i did this on a project, by replacing the ezdesign and ezimage operators directly in the template with other operators (ezdesign_static & ezimage_static), when using ezjscore you may need to dive deeper.

Taking a look at the

ezjscPacker::buildStylesheetTag( .. )

method, and potentially overriding it of possible, could help. A good alternative is to post an enhancement request in this regard, there : http://issues.ez.no/ProjectSelect.php?Id=3

Cheers !

Thursday 17 June 2010 7:23:45 pm

OK, I've added this as an enhanchement:

http://issues.ez.no/IssueView.php?Id=16920

Thursday 17 June 2010 7:55:56 pm

Excellent.

Cheers !

Friday 18 June 2010 3:00:46 pm

This is already supported guys!

Take a look in ezjscore.ini [Packer]CustomHosts[]

Friday 18 June 2010 4:11:32 pm

Man this ezjscore extension rocks even more than i thought !

Thanks for the feedback Andre !

Saturday 19 June 2010 12:31:30 pm

Side note: eZ Publish also supports filters that can be run on the rendered page (pagelayout + module view) as last step.

IIrc the xrowcdn extension uses this feature to rewrite the urls generated by eZ to point them to a CDN.

Might be useful for scenarios where not only the ezjscore urls need to be rewritten (even though I'd go for adding a new tpl operator and use it prepended to ezimage/ezdesign instead)

Sunday 20 June 2010 6:40:59 pm

This is already supported guys!

Take a look in ezjscore.ini [Packer]CustomHosts[]

Andre, I have eZP 4.1.3 and I don't have this setting in ezjscore.ini. From which version is available?

Another question: Will this work without problems for font urls in CSS? (thinking of @font-face)

Sunday 20 June 2010 6:45:24 pm

Gaetano, I know about xrowcdn and I'm already planning to use it. The only question is if I can use it with my "kind of" CDN. I posted the question in the forum:

http://projects.ez.no/xrowcdn/forum/general/is_custom_cdn_possible

and I'm waiting for an answer.

In addition: where can I find some docs about this filters that can be run on the rendered page?

Thursday 24 June 2010 1:55:24 am

Hi Hubert,

xrowcdn can work fine for your need, I was just looking for this too. This is how i did.
Install the xrowcdn extension

In the xrowcdn.ini file I changed all the Replacement=http://<uniquecloudfrontname>.cloudfront.net with the url I have for "my" own cdn and put put UseGZIP=enabled

I've added the OutputFilter in my siteaccess site.ini file

Backuped the db just in case

generate the autoload again

emptied the cache, and it was ok.

Hope it helps,

Nicolas

Thursday 24 June 2010 11:34:19 am

Another question:

Does ezjscore support output filters?

For example if I want to use some of my custom tags in CSS and parse them at the output.

Tuesday 06 March 2012 4:19:08 pm

Quote from André R :

This is already supported guys!

Take a look in ezjscore.ini [Packer]CustomHosts[]

I tried this on an eZ Publish 2011.9 installation, but it only half worked. With:

[Packer]
CustomHosts[.css]=http://media2.example.com
CustomHosts[.js]=http://media1.example.com

Only the Javascript URLs are changed. I looked at the PHP in ezjscore and couldn't see any reason why it might be ignoring the CSS setting.

Any ideas?

Thursday 12 July 2012 2:56:38 pm

Quote from Andy Caiger :
Quote from André R :

This is already supported guys!

Take a look in ezjscore.ini [Packer]CustomHosts[]

I tried this on an eZ Publish 2011.9 installation, but it only half worked. With:

[Packer]
CustomHosts[.css]=http://media2.example.com
CustomHosts[.js]=http://media1.example.com

Only the Javascript URLs are changed. I looked at the PHP in ezjscore and couldn't see any reason why it might be ignoring the CSS setting.

After experiencing the same thing, and a bit of investigation, I can see the problems:

  1. ezcss_load & ezcss allow you to specify the type of media (all, print, screen etc) - you'll see this at the end of the packed CSS file
  2. This gets passed to the ezjspacker::buildStylesheetTag method as a parameter, which gets concatenated and passed to the packFiles method as the "file extension"

So there are two solutions:

  1. CustomHosts[_all.css]=http://media2.example.com
  2. Fix the packFiles method in classes/ezjspacker.php to parse out everything but the file extension when setting the CustomHost - pull request submitted.

Cheers,

Geoff

Modified on Friday 13 July 2012 2:21:37 pm by Geoff Bentley

Monday 16 July 2012 5:22:19 am

This is great! Thanks very much Geoff!

Andy

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from