Welcome Guest, Not a member yet? Register   Sign In
PHP includes aren't working in CI
#10

[eluser]Unknown[/eluser]
I had a similar problem and a nice person in the IRC channel pointed me at the Django-like template inheritance helper (found here).

Say if you have a view called 'base.php' with:
Code:
<html>
<head>
    <title>Wooshy -  <? start_block_marker('title') ?>Home<? end_block_marker() ?></title>
</head>

<body>
<h1>&lt;? start_block_marker('heading') ?&gt;Home&lt;? end_block_marker() ?&gt;</h1>
<ul id="navigation">
    <li>&lt;?=anchor('/','Home')?&gt;</li>
    <li>&lt;?=anchor('/about','About')?&gt;</li>
</ul>
&lt;? start_block_marker('content') ?&gt;
    <h2>Welcome</h2>
    <p>Filler</p>
&lt;? end_block_marker() ?&gt;
&lt;/body&gt;
&lt;/html&gt;

and in your 'about.php' view you have:
Code:
&lt;?php
extend('base.php');

startblock('title');
echo $title;
endblock();

startblock('heading');
echo $heading;
endblock();

startblock('content');
echo "<p>Some text</p>"
endblock();


end_extend();
?&gt;

You can simply load the 'about.php' view and it will automatically inherit the html from base.php.
Code:
$vars['title'] = "About us";
$vars['heading'] = "All about our nice team";
$this->load->view('about.php',$vars);

Nice or what Smile Hope this may help.


Messages In This Thread
PHP includes aren't working in CI - by El Forum - 05-25-2008, 03:28 AM
PHP includes aren't working in CI - by El Forum - 05-25-2008, 03:38 AM
PHP includes aren't working in CI - by El Forum - 05-25-2008, 03:44 AM
PHP includes aren't working in CI - by El Forum - 05-25-2008, 03:52 AM
PHP includes aren't working in CI - by El Forum - 05-25-2008, 05:43 AM
PHP includes aren't working in CI - by El Forum - 05-25-2008, 06:35 AM
PHP includes aren't working in CI - by El Forum - 05-25-2008, 06:49 AM
PHP includes aren't working in CI - by El Forum - 05-25-2008, 06:54 AM
PHP includes aren't working in CI - by El Forum - 05-25-2008, 09:22 AM
PHP includes aren't working in CI - by El Forum - 05-25-2008, 10:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB