Welcome Guest, Not a member yet? Register   Sign In
Create a WebSite - Template/Multiple Views
#6

[eluser]jedd[/eluser]
Quote:thanks for trying to help me, but i'm getting even more confused..

This is perfectly normal. Things get worse before they get better. Try to relax. Pretend you're on a beach.

With a very nice laptop.

Okay .. you're asking for something that is quite normal, and lots of people have trodden this path before, so I'm sure we'll be fine.

Quote:let's say it like this, how do you create a simple website with header / menu (horizontal) / content / rightbar with some custom 'modules' / footer ?

Okay - what I've done is pilfered someone else's code. I took the idea from [url="http://ellislab.com/forums/viewthread/106945/#538402"]this post[/url] and modified it slightly.

All my pages are rendered by this view file - default.php :

Code:
<html>
<head>
<?php
    // Grab the theme to use.
    $theme = $this->session->userdata('theme');

    // Use the right CSS
    echo link_tag('assets/stylesheets/'. $theme .'.css')
?>

<?php // jquery loader goes in here , but is stripped by CI Forum for security reasons ?>

<title>
    <?= $title ?>
</title>
</head>
<body>

<?php
?>

<div id="div_everything_wrapper">
    
    <div id="div_topbar_wrapper">
        &lt;?php echo $top_bar_view; ?&gt;
    </div>

    <div id="div_torso_wrapper">

        <div id="div_navigation_menu">
            &lt;?php echo $main_menu_view; ?&gt;
        </div>

        <div id="div_main_content">
            &lt;?php  echo $main_text_view;  ?&gt;
        </div>

        <div class="break">
        </div>

    </div>

    <div id="div_footer_wrapper">
        &lt;!-- Don't want to pre-render this or it throws our profiling out --&gt;
        Rendered in {elapsed_time}s, and {memory_usage}.
    </div>
</div>


&lt;/body&gt;
&lt;/html&gt;

The left/right/top/bottom stuff you mention is obviously sorted by CSS, but I gather you're hip with that? Happy to upload my rather exuberant CSS file if you're interested .. and masochistic. Obviously, in the above, my navigation menu is on the left, main content is on the right, and I've got top and bottom bars of varying complexity.

Now, equally obviously, all those data I refer to in there need to get generated somewhere.

They all come in as part of the $data array from whichever controller calls this default view. But note that each of my controllers generates (as a rule) ONLY one variable - the $main_text_view component, which is obviously the meat in the web sandwich. All the other bits of data there are generated in MY_Controller.

I've actually just written a wiki page - [url="http://codeigniter.com/wiki/MY_Controller_-_how_to_extend_the_CI_Controller/"]MY_Controller - how to extend the CI Controller[/url] which you might want to have a read of now. Let me know if it needs any modifications.

In my MY_Controller file I make topbar_view, title, and the navigation_menu and insert them all into $this->data at that point (so they appear in $this->data in all your controllers too - you're hip with this side of things, yes?

Quote:* the menu is dinamically loaded from the database, how would you proceed?

Okay, slightly more complex, but not hugely so. You should be able to talk to your Model via MY_Controller - though I haven't actually done this. I'm not sure when the database class gets loaded - but I'd imagine far enough back up that it is usable (I'm an optimist at heart).

Certainly if you work through this stuff above, and get stuck at the dynamic / database generation of your menu, there'll be plenty of interest in helping you over that hurdle.


Messages In This Thread
Create a WebSite - Template/Multiple Views - by El Forum - 03-16-2009, 12:38 PM
Create a WebSite - Template/Multiple Views - by El Forum - 03-16-2009, 12:46 PM
Create a WebSite - Template/Multiple Views - by El Forum - 03-16-2009, 01:14 PM
Create a WebSite - Template/Multiple Views - by El Forum - 03-16-2009, 03:50 PM
Create a WebSite - Template/Multiple Views - by El Forum - 03-16-2009, 05:00 PM
Create a WebSite - Template/Multiple Views - by El Forum - 03-16-2009, 05:20 PM
Create a WebSite - Template/Multiple Views - by El Forum - 03-16-2009, 05:25 PM
Create a WebSite - Template/Multiple Views - by El Forum - 03-16-2009, 05:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB