[SOLVED] font-face on one domain name failing

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
User avatar
thomahawk
Power Poster
Power Poster
Posts: 293
Joined: Fri Jul 25, 2008 10:13 am
Location: Zug, Switzerland

[SOLVED] font-face on one domain name failing

Post 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?
Last edited by thomahawk on Mon Nov 03, 2014 6:49 pm, edited 1 time in total.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1921
Joined: Mon Jan 29, 2007 4:47 pm

Re: font-face on one domain name failing

Post 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.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
thomahawk
Power Poster
Power Poster
Posts: 293
Joined: Fri Jul 25, 2008 10:13 am
Location: Zug, Switzerland

Re: font-face on one domain name failing

Post 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.
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: font-face on one domain name failing

Post 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')
User avatar
thomahawk
Power Poster
Power Poster
Posts: 293
Joined: Fri Jul 25, 2008 10:13 am
Location: Zug, Switzerland

Re: font-face on one domain name failing

Post 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.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1921
Joined: Mon Jan 29, 2007 4:47 pm

Re: font-face on one domain name failing

Post 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....
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Location: Maidenhead, UK
Contact:

Re: font-face on one domain name failing

Post 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? ???
User avatar
thomahawk
Power Poster
Power Poster
Posts: 293
Joined: Fri Jul 25, 2008 10:13 am
Location: Zug, Switzerland

Re: font-face on one domain name failing

Post 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.
Post Reply

Return to “Layout and Design (CSS & HTML)”