• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making fonts awesome work ?

#1
I've been struggling with fa fa icons not showing up. Then I found this solution on SO and it worked:

That's in config.php, I used to have $config['base_url'] = 'http://www.mysite.ca' Then I changed it to:

Code:
$root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST'];
$root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;

Is this a standard way to make fonts awesome work or there is a simpler way? And why it worked when I changed it?

CI 2.2.2
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
Reply

#2
Font aewesome has nothing to with CI, its just html/css stuff.

Be shure you use the same protocol to load your own site and load FA , so both has to be either http or https, otherwise it would get loaded due to mixed content.
Reply

#3
(05-31-2015, 12:11 PM)lexxtoronto Wrote: I've been struggling with fa fa icons not showing up. Then I found this solution on SO and it worked:

That's in config.php, I used to have $config['base_url'] = 'http://www.mysite.ca' Then I changed it to:


Code:
$root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST'];
$root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;

Is this a standard way to make fonts awesome work or there is a simpler way? And why it worked when I changed it?

CI 2.2.2

If you autoload url helper also and place the code below in header http://fortawesome.github.io/Font-Awesome/get-started/


Code:
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply

#4
Thanks @lexxtoronto it helped me at dead end.. Thank alot
Reply

#5
Code:
<head>
<!-- Put the <base> tag as the first element inside the <head> element. -->
<base href="<?php echo base_url(); ?>">
</head>
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#6
It is also better to download the font awesome assets directly and link to them locally. Loading assets from a server you don't control is never a good idea.
Reply

#7
(03-14-2016, 07:07 PM)PaulD Wrote: It is also better to download the font awesome assets directly and link to them locally. Loading assets from a server you don't control is never a good idea.

While generally this is true, it's not always a bad idea to use assets from cdn's like google. Not only are google cdns just as likely to not go down as your site, millions of people have already cached the library from there, making it one less thing to pull from your server and make your page load quicker.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply

#8
Yes, you are right about that. "never a good idea" was perhaps a bit strong. You also always get the latest version of course.

However, I could be wrong here, but when you link to say a google font, or font awesome, in the <head> or @import in the css, every time the page is loaded the page has to communicate with the google server to access the relevant data. That surely must take longer than collecting a local file you have downloaded and made available on your own server.

For instance, I often see a pause on loading sites while it is 'waiting for google analytics..' etc.

However, I suppose the browser loads the resources separately anyway, so does it matter if it is getting it from your server or elsewhere? I really don't know - lack of basic understanding on my part showing here I suspect.
Reply

#9
(05-31-2015, 12:11 PM)lexxtoronto Wrote: I've been struggling with fa fa icons not showing up. Then I found this solution on SO and it worked:

That's in config.php, I used to have $config['base_url'] = 'http://www.mysite.ca' Then I changed it to:

Code:
$root=(isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST'];
$root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;

Is this a standard way to make fonts awesome work or there is a simpler way? And why it worked when I changed it?

CI 2.2.2

Just set your base url to your site root url that also works.


Code:
$config['base_url'] = 'http://localhost/ci';
Reply

#10
(03-14-2016, 05:07 PM)InsiteFX Wrote:
Code:
<head>
<!-- Put the <base> tag as the first element inside the <head> element. -->
<base href="<?php echo base_url(); ?>">
</head>

Thanks a lot bro InsiteFX. It works like charm.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.