Welcome Guest, Not a member yet? Register   Sign In
include views and have more controllers to be used?
#1

[eluser]Schumacher[/eluser]
I know that the title might be a little misunderstanding but i didn't know what els to go for.
Just to say: I'm new at code igniter, but i find it very interesting but there are some things and can't see my way out of.

Lets start.

I have thing ideer of building this site, and i would like to use code igniter to it, but, there are some problematics with it, and some problems i can't see my way out of without any help.
On the site i have a header, left content, mid content, right content and footer. And these 5 'places' are in a view for them selves. I got a template.php view that includes them all so i got it all in one file.
But my question is, if i have a login in the left content, and is should be posable to login in that place, and when the person is logged in there is a profil menu. How do i get a controller du handle this? when i also have to have a controller to control the other stuff going on , on the site. How can i do this and still have a useable url ?
Do i need to have a master controller or what?
Hope this makes sense, and think that im not the first to have this problem.
Fell free to post a better way to set up my views, thats just what ive seen ppl do.

// Schumacher
#2

[eluser]n0xie[/eluser]
This question is so common, that an entire part of the wiki has been devoted to it:
Header and Footer on every page
#3

[eluser]karthik86[/eluser]
[quote author="Schumacher" date="1264433775"]I know that the title might be a little misunderstanding but i didn't know what els to go for.
Just to say: I'm new at code igniter, but i find it very interesting but there are some things and can't see my way out of.

Lets start.

I have thing ideer of building this site, and i would like to use code igniter to it, but, there are some problematics with it, and some problems i can't see my way out of without any help.
On the site i have a header, left content, mid content, right content and footer. And these 5 'places' are in a view for them selves. I got a template.php view that includes them all so i got it all in one file.
But my question is, if i have a login in the left content, and is should be posable to login in that place, and when the person is logged in there is a profil menu. How do i get a controller du handle this? when i also have to have a controller to control the other stuff going on , on the site. How can i do this and still have a useable url ?
Do i need to have a master controller or what?
Hope this makes sense, and think that im not the first to have this problem.
Fell free to post a better way to set up my views, thats just what ive seen ppl do.

// Schumacher[/quote]

While not wanting to make things complicated you can just use a session variable which most obviouslly u ll use to check if the user logged in, and depending on that display what ever you need...
#4

[eluser]Schumacher[/eluser]
Arn't there a guide / tutorial to this ?

And which would be most appropriate for bigger sites.
#5

[eluser]veritascs[/eluser]
Not sure if you have checked out the approaches at Header and Footer and Menu on every page but my approach was to make a helper file that my controllers can use to load page data. Example from my code:

controllers/home.php
Code:
function index()
    {
        $this->load->helper('template_helper');

        //load all page content before this pages main content
        preContent();
        
        //get the blog entries
        $this->load->model('blog_model');
        $main_data['blog_results'] = $this->blog_model->get_last_five_blogs();
        $this->load->view('main_view', $main_data);

        //load all page content after this pages main content
        postContent();
    }

helpers/template_helper.php
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if(!function_exists('preContent'))
{
    function preContent($js_files = array(), $css_files = array()) {
        $CI =& get_instance();
        //load helpers
        $CI->load->helper('url');         //for base_url()
        $CI->load->helper('html');        //for doctype()
        $CI->load->helper('date');        //for unix_to_human()

        //maybe get dynamic data and then load hte view?
        $header_data['title'] = '//eFlow';
        $header_data['js_files'] = $js_files;
        $header_data['css_files'] = $css_files;

        //get the nav menu items
        $CI->load->model('nav_model');
        $nav_data['nav_items'] = $CI->nav_model->allNavItems();

        //load the different views
        $CI->load->view('header_view', $header_data);
        $CI->load->view('nav_view', $nav_data);

        //get session data
        $left_content_data['sessionInfo'] = $CI->session->all_userdata();
        $CI->load->view('left_content_view', $left_content_data);
    }
}

if(!function_exists('postContent'))
{
    function postContent(){
        $CI =& get_instance();

        $CI->load->view('footer_view');
    }
}


/* End of file template_helper.php */
/* Location: ./system/applicaton/helpers/template_helper.php */

I'm really new to CI and the MVC pattern so feedback would be greatly appreciated if this is an illogical approach.




Theme © iAndrew 2016 - Forum software by © MyBB