Welcome Guest, Not a member yet? Register   Sign In
Suggestion on how to do a site like codeigniter.com
#1

[eluser]ted wong[/eluser]
http://codeigniter.com/

It have a shared menu bar, for many pages, I will think the page in main controller, with many little controllers, for example:
home controller, download controller, news controller , etc. But I would like to know, how can make them have a sharing menu, for header, footer, instead of using the same codes, can I make a big main controller to load them? What is your suggestions? Thank you.
#2

[eluser]jblack199[/eluser]
You can do it how I did it, in my view I created an includes folder which has a header.php, footer.php and a template.php

my template.php:
Code:
<?php $this->load->view('adm/includes/header'); ?>

<?php $this->load->view($main_content); ?>

<?php $this->load->view('adm/includes/footer'); ?>

note: my paths have the adm for this, specifically because this is for the administration panel for my site.

my header.php is just that, all the html and php to create the header and everything else... footer.php again all the html and php needed to create my footer..

then in my controller i do:

Code:
$data['main_content'] = 'view_name';
$this->load->view('includes/template', $data);

and it'll work for you... not too tricky to get it to work.
#3

[eluser]ted wong[/eluser]
But what if I would like to pass some param in the your main_content?
I have a template doing all html, backdrop stuff, and I would like to have dynamic content in my main_content.

Thank you.
#4

[eluser]jblack199[/eluser]
you'd do that just like normal... your main_content is nothing more than the middle part of the page whether thats pure html or php (like a loop to make a list) or whatever... using that only your imagination and coding skills is your limit.

using the code above, all that it is for is to get the standard header/footer on every page without having to use the html for it in every view file thus making the site easier to edit and manage in the future.




Theme © iAndrew 2016 - Forum software by © MyBB