Welcome Guest, Not a member yet? Register   Sign In
how include VIEW outside the codeigniter?
#1

[eluser]Radiart[/eluser]
Hi

I use Codeingiter 1.7.3 and I attempts integrate it with IP Board 3.1.3

I need to include header and footer from Codeigniter, I use this code in IP Board template:

Code:
<php>
  include 'http://localhost/break/application/views/global_header.php';
</php>

It working but including all main page of website

I need include only VIEW global_header.php

Do you know how to do it?
#2

[eluser]Georgi Budinov[/eluser]
Interesting task ....

On the place where you need to output the view you can do this:

Code:
$tmpPathInfo = $_SERVER['PATH_INFO'];
$tmpRequestUri = $_SERVER['REQUEST_URI'];
$_SERVER['PATH_INFO'] = '/outside/view1'; // A custom controller to with method view1 that acually loads the view
$_SERVER['REQUEST_URI'] = '/outside/view1';
require(CI_INDEX); // CI_INDEX is absolute path to CI index
$_SERVER['PATH_INFO'] = $tmpPathInfo;
$_SERVER['REQUEST_URI'] = $tmpRequestUri;

Not tested the code but should work ...
#3

[eluser]Radiart[/eluser]
Sorry but I don't know how tu use this.

When I pute this I have error's.

Can U write more how to use this code?
#4

[eluser]Atharva[/eluser]
Assuming your file is on root folder (folder where index.php and system folder resides)

Code:
define( 'BASEPATH', dirname(__FILE__) );

include( BASEPATH  .'/system/application/views/global_header.php' );
#5

[eluser]Radiart[/eluser]
But I know the path. Path is correctly and including working.

The problem is that the Codeigniter include whole main page: break/index.php, I need include only break/apllication/view/global_header.php

break - folder where is application and system folder

I want include only one VIEW not whole page in another application It possible?
#6

[eluser]Phil Sturgeon[/eluser]
A view is a PHP file, you can include a PHP file directly but it will only parse the data that is provided to it. If you want to scrape the HTML from your CodeIgniter site you can use curl or file_get_contents() to grab the entire output and leave a HTML comment in the header to explode on.

This sounds weird but is pretty common, I had to do this to integrate MSN's template into the MSN Money UK website a year or two back. Dirty, dirty, madness.




Theme © iAndrew 2016 - Forum software by © MyBB