Welcome Guest, Not a member yet? Register   Sign In
What's the equivalent of PHP Includes in CI
#1

[eluser]Bionicjoe[/eluser]
I'm making some headway learning CI, but before I get too far how do I re-use code for site's pages like you do with PHP includes?

Specifically I have all my header, css, basic layout info at the top of two view pages. I want to use the same info on all pages.
Do I:
A) Create a php include file and use it like any other non-CI php project?
B) Use CI model/views to call and insert the same code?

The type of junk on every page.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;&lt;?php echo $title ?&gt;&lt;/title&gt;
        &lt;meta http-equiv="Content-Type" content="text/html"; charset=UTF-8"&gt;    
        &lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url(); ?&gt;system/application/css/layout.css" media="screen"&gt;
    &lt;/head&gt;
    
    &lt;body&gt;
#2

[eluser]jedd[/eluser]
You can still use include() .. but by the sounds of it, this isn't what you need here.

Have a read of [url="/wiki/Header_and_Footer_and_Menu_on_every_page_-_jedd/"]my header & footer on every page[/url] wiki entry. And perhaps in conjunction, the wiki page on [url="/wiki/MY_Controller"]MY_Controller[/url] (if you haven't got one already, you probably want one).
#3

[eluser]Bionicjoe[/eluser]
Thanks.

I'm finding answers now. Forgot to check Wiki. D'oh!




Theme © iAndrew 2016 - Forum software by © MyBB