ismail khan
ismail khan

Reputation: 307

CodeInteger Error Message: Message: Call to undefined function link_tag(

<title>Login</title>

    <!-- CSS -->
   <?php echo link_tag('assets/css/bootstrap.min.css')?>
    <?php echo link_tag('assets/font-awesome/css/font-awesome.min.css')?>
   <?php echo link_tag('assets/css/form-elements.css')?>
    <?php echo link_tag('assets/ico/favicon.png')?>
   <?php echo link_tag('assets/ico/apple-touch-icon-144-precomposed.png')?>
   <?php echo link_tag('assets/ico//apple-touch-icon-114-precomposed.png')?>
   <?php echo link_tag('assets/ico//apple-touch-icon-72-precomposed.png')?>
    <?php  echo link_tag('assets/ico//apple-touch-icon-57-precomposed.png')?>
</head>

i did not write any Controller or Model class , just to include the above Styles and Images in page , it show the Message: "Message: Call to undefined function link_tag()"Error even i have wrote the following code also in config/autoload file $autoload['helper'] = array('url');"" Error e

Upvotes: 1

Views: 1846

Answers (3)

Deniz B.
Deniz B.

Reputation: 2562

link_tag() is a function which defined in HTML helper. You should load HTML helper first.

You have 2 options, first one:

Open, application/config/autoload.php and add 'html' value in helper array.

Second one:

Add this line top of your code.

$this->load->helper('html');

Then, edit your lines like this:

    $link = array
          (
           'href' => 'assets/css/bootstrap.min.css',
           'rel' => 'stylesheet',
           'type' => 'text/css',
          );

echo link_tag($link);

But I think you can just use site_url() function. If you want to use site_url(), you should load url helper and edit your lines like below:

<link href="<?php echo site_url('assets/css/bootstrap.min.css'); ?>" rel="stylesheet" type="text/css" />

Upvotes: 2

Hanan Ashraf
Hanan Ashraf

Reputation: 518

Try using base_url(); instead.

 <?php echo base_url('assets/css/bootstrap.min.css')?>

Upvotes: 0

pr0metheus
pr0metheus

Reputation: 488

You using wrong helper. You should add to your autoload 'html'

Please check documentation

https://ellislab.com/codeigniter/user-guide/helpers/html_helper.html#link_tag

Upvotes: 0

Related Questions