Welcome Guest, Not a member yet? Register   Sign In
CI and Smarty - layout issues
#1

[eluser]Freakish_05[/eluser]
Hello everyone!

I'm very new to CI (started on Friday) but I've already picked up quite a bit of it. I've also integrated smarty and I've got that working well too.

My problem is that, before using CI, I used to have an index.php file which contained all the header information etc and then had php includes for the navbar (database stored links), the sidebar (also with database stuff) and content which is obviously the meat of the page.

Using Smarty I've been able to include 'header.tpl', 'footer.tpl' and 'side.tpl' but the problem is that all of these elements (except 'footer.tpl' need to display dynamic elements. These will obviously need to have separate controllers.

I've been searching these forums for viable solutions and coolfactor's extended myview class appears to be the best solution for CI only apps, I'm not sure how I'd apply it to Smarty though :-S

Any help greatly appreciated,
Freakish_05
#2

[eluser]Freakish_05[/eluser]
I've just had a thought.... Could I not just include the controller files for each of the page blogs in each of the 'content' controllers.

Example of 'content' Controller
Code:
<?php

Class Blog extends Controller
{
    function Blog()
    {
        parent::Controller();
        require_once("./header.php");
        require_once("./sidebar.php");
    }

    function index()
    {
        //Some other code here to create the initial 'blog' view
    }
}
Does that seem like a viable way of doing things? 'header.php' and 'sidebar.php' will output their own Smarty '.tpl' file, supposedly.

Freakish_05
#3

[eluser]Phil Sturgeon[/eluser]
You could but its a bit dirty.

Why not make your own library or helper functions for output. Calls up all the default data you need then outputs them all together?

If you do it the way above you would have to call the classes, like:

Code:
$header = new Header();
$header_code = $header->index();

That was is REALLY bad!




Theme © iAndrew 2016 - Forum software by © MyBB