CodeIgniter Forums

Full Version: Pleeease: Help me with Site Structure - from one page example, to a multipage example
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

Hello, I'm trying do develop my first site with CI. I'm new to MVC, CI, PHP and OOP in general. However, I'm making my way to those.

I've read a LOT on those forums threads by search the Keyworks "Site Structure", and also google a lot on those subjects, still can't find my way to go.

To make this worst, I have follow some tutorials that, actually, teach you the basic, but never give your the wide picture. You know how to add, remove, delete, use the mailer class or other things like that, but you still don't know how to work will multiple controllers and views. And, this is, à mon avis, one of the worst steps to accomplish: Understanding the wide strutucture of creating a website.

Because of all this, I'd like to ask your comprehension and help on this:

Based on some tutorials online I'm now close to this structure for a hypothetical product list page:

<div id=”header”
    <h1>&lt;?php echo $header;?&gt;</h1>
    <p>this is my header</p>

<div id=”content”
    &lt;?php foreach ($products as $product):?&gt;
        <p><strong>Name:</strong>&lt;?php echo $product->name;?&gt;</p>
&lt;?php endforeach;?&gt;

<div id=”footer”
    &lt;?php echo $footer; ?&gt;
    <p>o this is my footer</p>

Class Page extends Controller
  function Page()

  function  índex()
    $data[‘header’]=$this->load->view(‘header_view’,array(‘header’=>’Header Zone’), TRUE);
$data[‘content’]=$this->load->view(‘content_view’,array(‘product’=>$this->Product->getAll() ), TRUE);
    $data[‘footer’]=$this->load->view(‘footer_view’,array(‘footer’=>’Footer Zone’), TRUE);

    $this->load->view(‘main_page’, $data);

Finally I would have some kind of wrapper, like this, where all those components will be called.

    <div id=”container”>
        &lt;?php echo $header.$content.$footer;?&gt;

I'm trying to pass from this structure,to a structure that allows me to deal with several pages.

I'm not actually developing, only mockup the structure so, no deep code needed.

content_view.php is quite related to products, so maybe I will change the name to produt_view.php and then have other views as well.

The Class Page that extends Controller could also be renamed as product_list_controller and I will add other controllers for other pages as well...

To the wrapper I would call it product_list_view but again, I will end up with other views as well..

I could also think on having a controller class called institutional, and on each method on that controller class, I would point to a static page view.

I'm lost and desperate. Please help me out.

Please advice,

El Forum

Here are my favourite threads that I suggest to people who haven't found any hits in the forum search on 'header' and 'footer' - but there are hundreds more threads on this subject to choose from, if you don't like these two:

El Forum

Thanks jedd.

I've also found those:

This for admin section:

I still have no luck. Sorry. Maybe I need some rest of all this for a while.

Thanks anyway,

El Forum

Jumping into CodeIgniter without knowing PHP or OOP might be kind of like performing surgery before you've been to med school... If you want a strong foundation, you might want to tackle PHP first.

That being said, what exactly is your question? What are you seeing when the page loads? Are there any errors displayed or in the log? I don't see why your setup wouldn't work offhand, so my only guess is a syntax error somewhere.

I wonder why you're trying to load the views as data, though, since you're not doing anything with the data. You could just call:
$this->load->view('header_view',array('header'=>'Header Zone'));
$this->load->view('footer_view',array('footer'=>'Footer Zone'), TRUE);

Or, more logically, include the wrapper portions in your header and footer. Hope that helps.

El Forum

Actually, templating is more what you're looking for. Anything else is not really going to satisfy you.

There are other tools available, but I explain my preferred, simple, solution here:

El Forum

I have been on PHP OOP I was trying to make my way to a personal framework, and then I die on the MVC model. Confused
And trying to deal with Pagination, Validation, Login classes all together and related...WOW, nightmare, so... I'm trying to keep learning OOP, more PHP, MVC but using the CodeIgniter help. Smile

Normally I don't rush to the code, and I stay 70% or 80% of the development time over the structure. So I can't see any error for now, because I'm just trying to understand how the skeleton on this work.

The best I can find is Validation with Codeigniter, Pagination with Codeigniter, Anyspecificmodules with codeigniter, but, the big one, the ALL, the A Website Struture with Codeigniter the best I can find are "half" blogs that promisse a all revision but die on the introdution.

I will never forget this past days, and I'm sure one day I will create a "Example Complete Structure on a Common Website with Codegigniter". Smile

The template helps me structurating the views, and have views separed from logic, but I also need a way to learn, how to structure the controllers. But please, no more links. I have a lot already. Smile

I will consider all your replies, and I will rest for some hours and then, try to come back with a structure code based on your replies.

Thanks a lot,