Welcome Guest, Not a member yet? Register   Sign In
Problem with URL Helper functions
#1

[eluser]chzigkol[/eluser]
Hello to everyone,

I'm trying to get the base_url() value in a HTML code snippet and I take the following error

Fatal error: Call to undefined function base_url() in ....

I have also enabled the appropriate helper in the autoload.php config file but nothing happened

The funny is that I get no errors when I use the same function in a view that I load from a controller. Contrary to this, the above HTML code snippet is called by another view file.

Can anyone help me with this?

Thanks in advance
#2

[eluser]Phil Sturgeon[/eluser]
Have you run $this->load->helper('url') in your controller?

I always add this helper into the applciation/config/autoload.php as I use it pretty much everywhere. You might consider doing the same.
#3

[eluser]davidbehler[/eluser]
Where exactly is that "HTML code snippet"? In a view file? Outside of CI?
#4

[eluser]chzigkol[/eluser]
It's outside of CI but I get the same error when I put it in the view directory.

Perhaps the helper's functions work only in view files that have been loaded by some controller. And my file is loaded by a view like this

<?php require base_url().'just a path';?>
#5

[eluser]Phil Sturgeon[/eluser]
You cannot include a file via URL. Just use the path.
#6

[eluser]chzigkol[/eluser]
problem solved. Thanks for your assistance




Theme © iAndrew 2016 - Forum software by © MyBB