Welcome Guest, Not a member yet? Register   Sign In
Pleeease: Help me with Site Structure - from one page example, to a multipage example
#1

[eluser]MEM[/eluser]
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:

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

content_view.php
Code:
<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>

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


Code:
Class Page extends Controller
{
  function Page()
  {
    parent::Controller;
    $this->load->model(‘Product’)
  }

  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.

Code:
<!DOCTYPE html PUBLIC …..
&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
    <div id=”container”>
        &lt;?php echo $header.$content.$footer;?&gt;
    </div>
&lt;/body&gt;
</htm>


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.


WHAT I DO SEE:
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,
Márcio


Messages In This Thread
Pleeease: Help me with Site Structure - from one page example, to a multipage example - by El Forum - 08-21-2009, 01:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB