CodeIgniter Forums
Making fonts awesome work ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Making fonts awesome work ? (/thread-61921.html)



Making fonts awesome work ? - lexxtoronto - 05-31-2015

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


RE: Making fonts awesome work ? - Diederik - 05-31-2015

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.


RE: Making fonts awesome work ? - wolfgang1983 - 05-31-2015

(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">



RE: Making fonts awesome work ? - pgfepale - 03-14-2016

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


RE: Making fonts awesome work ? - InsiteFX - 03-14-2016

Code:
<head>
<!-- Put the <base> tag as the first element inside the <head> element. -->
<base href="<?php echo base_url(); ?>">
</head>



RE: Making fonts awesome work ? - PaulD - 03-14-2016

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.


RE: Making fonts awesome work ? - albertleao - 03-14-2016

(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.


RE: Making fonts awesome work ? - PaulD - 03-15-2016

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.


RE: Making fonts awesome work ? - AmarBunty - 05-05-2016

(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';



RE: Making fonts awesome work ? - souravlove - 06-08-2018

(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.