• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unable to connect with CSS using base_URL and link_tag()

#1
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
Reply

#2
try <?= link_tag('/assets/css/bootstrap.min.css') ?>
Simpler is always better
Reply

#3
https://codeigniter.com/user_guide/helpe...elper.html

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

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

Thanks for reply.. not worked .. Sad
Reply

#5
(06-15-2017, 11:57 PM)hafizfarooq Wrote:
(06-15-2017, 05: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?
Reply

#6
(06-15-2017, 08:00 PM)natanfelles Wrote: https://codeigniter.com/user_guide/helpe...elper.html

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


Thanks for the reply ... not done  Sad
Reply

#7
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
Reply

#8
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'] = ''
Reply

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

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

PHP Code:
$config['base_url'] = 'localhost/ciblog/'
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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