Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anything like MasterPages on CodeIgniter Framework?

I am new to Code Igniter and I wish to know if there is anything that works like MasterPages do on .NET.

Also i was wondering where should i keep my public files, like scripts, styles and images.

Greetings, and Thank you in Advance

like image 507
Germán Rodríguez Avatar asked Jul 08 '10 03:07

Germán Rodríguez


3 Answers

Master views aren't built into the framework. To get a similar effect you can load the subview and pass that to the master view.

Controller :

class Items extends Controller
{
    function show($id)
    {
        $item = $this->item_model->get_item($id);

        // Load the subview
        $content = $this->load->view('item/show', array('item' => $item), true);

        // Pass to the master view
        $this->load->view('master_view', array('content' => $content));
    }
}

Master view :

<div id="header">
</div>
<div id="content">
    <?php echo $content; ?>
</div>
<div id="footer">
</div>

To answer your other question, I keep all Javascript scripts and CSS in directories in the root of my project.

like image 70
Stephen Curran Avatar answered Oct 31 '22 23:10

Stephen Curran


I'm not sure that they have anything exactly like a master page. CodeIgniter is more of an MVC framework and uses views and controls to build up pages. If you're new to CodeIgniter, net.TutsPlus has a real good series of videos that goes into some depth about how to use the framework for different scenerios. Take a look under the section called "Catch Up" to see the list of videos.

Hope this helps out some and good luck in your project.

like image 29
Chris Avatar answered Oct 31 '22 22:10

Chris


try this library

http://www.williamsconcepts.com/ci/codeigniter/libraries/template/?v141

like image 1
Flakron Bytyqi Avatar answered Oct 31 '22 21:10

Flakron Bytyqi