• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem in calling views

#1
Good day,

I'm having problem with calling the views. maybe this is a noob question but please help me.

let say:
view
* header.php
* homepage.php
* iiner_homepage.php

Controller
*homepage.php

Contorller (homepage.php)
PHP Code:
function index(){
 
 $this->load->view('homepage');
}
function 
call_inner_page(){
 
$this->load->view('inner_homepage');


In calling my inner page function my URL would be

localhost/CI/homepage/call_inner_page

my problem is when i try to include the header.php file in my inner_homepage i got error
in linking other files.

inner_homepage.php (VIEW)
PHP Code:
<?php include_once('header.php'); 

echo 
'im the inner page'?>

but everything in the header file is broken link.
like for example i put a logo
Code:
<img src="assets/img/logo.png" />

URL: localhost/CI/assets/img/logo.png

but when i run it in my inner homepage the URL like this

URL: localhost/CI/homepage/assets/img/logo.png

thanks in advance guys
Reply

#2
(09-23-2015, 12:41 AM)rhyszz Wrote: Good day,

I'm having problem with calling the views. maybe this is a noob question but please help me.

let say:
view
* header.php
* homepage.php
* iiner_homepage.php

Controller
*homepage.php

Contorller (homepage.php)

PHP Code:
function index(){
 
 $this->load->view('homepage');
}
function 
call_inner_page(){
 
$this->load->view('inner_homepage');


In calling my inner page function my URL would be

localhost/CI/homepage/call_inner_page

my problem is when i try to include the header.php file in my inner_homepage i got error
in linking other files.

inner_homepage.php (VIEW)

PHP Code:
<?php include_once('header.php'); 

echo 
'im the inner page'?>

but everything in the header file is broken link.
like for example i put a logo

Code:
<img src="assets/img/logo.png" />

URL: localhost/CI/assets/img/logo.png

but when i run it in my inner homepage the URL like this

URL: localhost/CI/homepage/assets/img/logo.png

thanks in advance guys

I think you should read the Ci user guide here http://www.codeigniter.com/user_guide/

in your case your answer is here http://www.codeigniter.com/user_guide/he...l#site_url
Reply

#3
(09-23-2015, 12:41 AM)rhyszz Wrote: Good day,

I'm having problem with calling the views. maybe this is a noob question but please help me.

let say:
view
* header.php
* homepage.php
* iiner_homepage.php

Controller
*homepage.php

Contorller (homepage.php)

PHP Code:
function index(){
 
 $this->load->view('homepage');
}
function 
call_inner_page(){
 
$this->load->view('inner_homepage');


In calling my inner page function my URL would be

localhost/CI/homepage/call_inner_page

my problem is when i try to include the header.php file in my inner_homepage i got error
in linking other files.

inner_homepage.php (VIEW)

PHP Code:
<?php include_once('header.php'); 

echo 
'im the inner page'?>

but everything in the header file is broken link.
like for example i put a logo

Code:
<img src="assets/img/logo.png" />

URL: localhost/CI/assets/img/logo.png

but when i run it in my inner homepage the URL like this

URL: localhost/CI/homepage/assets/img/logo.png

thanks in advance guys

Replace 

PHP Code:
<?php include_once('header.php'); ?>

With 

PHP Code:
<?php $this->load->view('header'); ?>
Romanian CodeIgniter Team :: Translations :: Comunity :: Developers
http://www.codeigniter.com.ro
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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