CodeIgniter Forums
unable to connect with CSS using base_URL and link_tag() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: unable to connect with CSS using base_URL and link_tag() (/showthread.php?tid=68247)

Pages: 1 2


unable to connect with CSS using base_URL and link_tag() - hafizfarooq - 06-15-2017

I am trying to connect with my CSS using link_tag() but system is not connecting... no errors .. nothing happens

Code:
<!DOCTYPE html>
<html>
   <head>
       <meta charset="UTF-8">
       <title>Articles List</title>
       <?= link_tag('assets/css/bootstrap.min.css') ?>
   </head>
   <body>
       <h1>Hellooooo</h1>
   </body>
</html>

in controller
PHP Code:
<?php
    class User 
extends MY_Controller
    
{
 
       public function index()
 
       {
 
           $this->load->helper('html');
 
           $this->load->view('public/articleslist');
 
       }
 
   }
?>

please help...
Farooq


RE: unable to connect with CSS using base_URL and link_tag() - donpwinston - 06-15-2017

try <?= link_tag('/assets/css/bootstrap.min.css') ?>


RE: unable to connect with CSS using base_URL and link_tag() - natanfelles - 06-15-2017

https://codeigniter.com/user_guide/helpers/url_helper.html

Use base_url('assets/css/bootstrap.min.css')


RE: unable to connect with CSS using base_URL and link_tag() - hafizfarooq - 06-15-2017

(06-15-2017, 04:54 PM)donpwinston Wrote: try <?= link_tag('/assets/css/bootstrap.min.css') ?>

Thanks for reply.. not worked .. Sad


RE: unable to connect with CSS using base_URL and link_tag() - Paradinight - 06-15-2017

(06-15-2017, 10:57 PM)hafizfarooq Wrote:
(06-15-2017, 04:54 PM)donpwinston Wrote: try <?= link_tag('/assets/css/bootstrap.min.css') ?>

Thanks for reply.. not worked .. Sad

white screen? or a page without css?


RE: unable to connect with CSS using base_URL and link_tag() - hafizfarooq - 06-15-2017

(06-15-2017, 07:00 PM)natanfelles Wrote: https://codeigniter.com/user_guide/helpers/url_helper.html

Use base_url('assets/css/bootstrap.min.css')


Thanks for the reply ... not done  Sad


RE: unable to connect with CSS using base_URL and link_tag() - hafizfarooq - 06-15-2017

The folowing way is working
<link rel="stylesheet" type="text/css" href="http://localhost/ciblog/assets/css/bootstrap.min.css">

But when try to get it dynamically.... it not works


RE: unable to connect with CSS using base_URL and link_tag() - Martin7483 - 06-16-2017

Do you have your base url set in your config?

PHP Code:
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| WARNING: You MUST set this value!
|
| If it is not set, then CodeIgniter will try guess the protocol and path
| your installation, but due to security concerns the hostname will be set
| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
| The auto-detection mechanism exists only for convenience during
| development and MUST NOT be used in production!
|
| If you need to allow multiple domains, remember that this file is still
| a PHP script and you can easily do that on your own.
|
*/
$config['base_url'] = ''



RE: unable to connect with CSS using base_URL and link_tag() - hafizfarooq - 06-16-2017

Thanks Martin for the reply.
I did it but not resolved the issue.
base_url = 'localhost/ciblog'


RE: unable to connect with CSS using base_URL and link_tag() - InsiteFX - 06-16-2017

You need to add the ending slash / onto the base url

PHP Code:
$config['base_url'] = 'localhost/ciblog/'