Page 1 of 1

[SOLVED] font-face on one domain name failing

Posted: Fri Oct 31, 2014 8:38 pm
by thomahawk
Hello all

I have a strange problem with font-face while using two domain names. One CMSM 1.11.7 “Genovesa” is installed. Two different domain names, one xxx.ch and one xxx.net point to the same CMSMS install. No specific domain name has been declared neither in config.php nor in htaccess.txt.

The fonts are within the same CMSMS folder and are linked from the internal stylesheet like this:

src: url('[[root_url]]/fonts/ag.eot')

But while on the .ch domain the pages appear well, with the fonts, the fonts do NOT appear with the .net domain. Checking the .net stylesheet for the website loaded in the browser, in fact the stylesheet URLs (also those of images) use the .ch domain.

Now the über-strange thing is, checking system informations in CMSMS, the root URL is correct, .ch after logging in via .ch login and .net after looging in via .net.

So why does [[root_url]] create always the .ch domain if its not specified anywhere?

Anyone having the same problem?

Re: font-face on one domain name failing

Posted: Fri Oct 31, 2014 10:07 pm
by Jo Morg
It has to do with with the way CMSMS combines and caches the stylesheets. That is also why you cannot pass variables from the templates to the stylesheets.
You may get away with some smarty conditionals on the template and use two sets of stylesheets depending on which domain is being requested. Something like (not tested):

Code: Select all

{nocache}
{if $smarty.server.SERVER_NAME == xxx.ch}
{cms_stylesheet name='css4xxx.ch'}
{elseif $smarty.server.SERVER_NAME == xxx.net}
{cms_stylesheet name='css4xxx.net'}
{/if}
{/nocache}
I'm not sure it will work, or if it is effective, but might be worth a try...
Remember to clear CMSMS cache after changes.
Otherwise you might have to embed the font on the main template instead.

Re: font-face on one domain name failing

Posted: Fri Oct 31, 2014 10:16 pm
by thomahawk
Thank you, Jo Morg. Yes, I cleared the cache several times without success. And strange is, I did the same thing before with other websites: two domain names, one CMSMS installation, and the fonts worked. I don't know what changed since then with CMSMS, but of course I am not happy about it.

Yes indeed, I found the easiest way to solve this is by making the stylesheet a document on the server and include it in the template like this

[literal]
<link href="styles.css" rel="stylesheet" type="text/css" />
[/literal]

But in my opinion CMSMS should (still) have so much flexibility for this to work instantly.

Re: font-face on one domain name failing

Posted: Sat Nov 01, 2014 12:48 am
by paulbaker
You shouldn't need to mention the root URL in the stylesheet at all (I don't).

Instead of:

Code: Select all

src: url('[[root_url]]/fonts/ag.eot')
Try:

Code: Select all

src: url('/fonts/ag.eot')

Re: font-face on one domain name failing

Posted: Sat Nov 01, 2014 7:43 am
by thomahawk
Thanks, Paul. Yes, I think the same, it should not be necessary. Previously I always made CSS URLs like url('/path/file') until this stopped working about 2 years ago. The solution was either include the full http://www.domain.com/path URL or [[root_url]]

I don't know how you do it to have it working without [[root_url]], but I just checked with a recent CMSMS 1.11.11, freshly installed and it is still so that without [[root_url]], links dont work from the internal stylesheet.

Re: font-face on one domain name failing

Posted: Sat Nov 01, 2014 11:26 am
by Jo Morg
On the other hand what might work is:

Code: Select all

src: url('../fonts/ag.eot')
edit: Had one period too many....

Re: font-face on one domain name failing

Posted: Sat Nov 01, 2014 9:57 pm
by paulbaker
thomahawk wrote:I don't know how you do it to have it working without [[root_url]],
Hmm, I don't either.

Example - I just grabbed this from a stylesheet within CMSMS from a working site (1.11.11):

Code: Select all

background-image: url(/uploads/images/SiteStructure/SeaAndSky.png);
Works perfectly. All my CSS urls are like that. Perhaps it's a server thing? ???

Re: font-face on one domain name failing

Posted: Mon Nov 03, 2014 6:48 pm
by thomahawk
Okay, I have it fixed. I had to do this in order to have the internal stylesheet working for both domains

url('../../../fonts/fontx.eot');

Before finding this, I made the font-face styles into an external css file. It worked too.. I thought... until today I found all pages except the frontpage, missing the fonts.

Then I thought maybe looking at the CSS in the browser via Firefox plugin Web Developer may help figure this out. I saw the location of the css is like
http://www.domain.ch/tmp/cache/stylesheet_combined_6534567fff576665hhg3bb.css so I came up with ../../../ before the font path and it worked.

Why don't you have the same problem? I don't know. You are just lucky. I don't think its a hosting server thing, the path /tmp/cache/ is certainly typical for CMSMS.