Welcome Guest, Not a member yet? Register   Sign In
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

(This post was last modified: 06-15-2017, 07:02 PM by natanfelles.)

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

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

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

Thanks for reply.. not worked .. Sad
Reply
#5

(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?
Reply
#6

(06-15-2017, 07: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 CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB