Reputation: 63
Can someone tell me if this code is codeigniter 3.0 compatible ? If not, how should it be formatted?
if ( ! function_exists('get_site_url'))
{
function get_site_url($data){
$CI =& get_instance();
//$data = '';
//echo base_url(); exit;
$data =str_replace('{SITE_URL}',base_url(),$data);
return $data;
}
}
Upvotes: 0
Views: 74
Reputation: 9
As you pass the $data['common_row'
] into the view section
$this->load->view('home_view',$data)
the data has been converted into a array is not object so when you are trying to get the data in the view you can try something like this <?php echo get_site_url($common_row['services']);?>
or <?php echo get_site_url($common_row[0]['services']);?>
depending upon the result.
You can debug the code and see the actual value by
print_r($common_row); die();
on the view page.
Upvotes: 0
Reputation: 6994
SITE_URL
is constant that you define using define('SITE_URL','value')
.So no need quotes ''
.Try like this..
if ( ! function_exists('get_site_url'))
{
function get_site_url($data){
$CI =& get_instance();
//$data = '';
//echo base_url(); exit;
$data =str_replace(SITE_URL,base_url(),$data);
return $data;
}
}
In order to use
base_url()
don't forget to loadurl
helper inapplication/config/autoload.php
Upvotes: 1