Welcome Guest, Not a member yet? Register   Sign In
Building my first site , review my structure plz
#1

[eluser]Peter74[/eluser]
Hello all, well times its come, iam gonna try to build my first site with ci, and iam a little nervious, and i have a few questions.

i like use templates, i buildt a couple (literaly two xD)a sites with that and always have the same question, cuz i like code with order, but always think... humm some missing here,
example:
i have :
header (login, flags, main nav, logo, site name)
content ("result of clicks")
footer (othermenu and stuff)

i like call ONE file to control de views, something like that

template ...
'HEADER'=> $data_header,
'CONTENT'=> $data_content, (maybe all page, example: user page, more menus, navs, etc)
'FOOTER'=> $data_content,
...
echo template
in this file, i change the information to show (content basiqly)

well, learning ci, i see a "pairs" of files (controller - view)
i dont know how is the "best" way (i know... it depends, dont tell me that plz)

questions:
how a make the structure for avoid create a entire page from zero.

I hope somebody understandme

----------
sorry about my spelling and redaction, iam learning english too
#2

[eluser]Jay Turley[/eluser]
[quote author="Peter74" date="1202348848"]questions:
how a make the structure for avoid create a entire page from zero.
[/quote]

With the 1.6 release of CodeIgniter, multiple views may be loaded by the controller, and they will be appended to the output in the order in which they are loaded.

For example, if I want to have a common header and a common footer for every page in my site, I might create three views: header_view.php, footer_view.php, and content_view.php

Then, in my controllers, I would have the following (in this example, I use the "foo" controller):
Code:
<?php

class Foo extends Controller {

   function index()
   {
      $data['page_title'] = 'Blah!';
      $data['page_content'] = "blah blah blah";
      $this->load->view('header');
      $this->load->view('content', $data);
      $this->load->view('footer');
   }

}
?>

The foo controller will load the header, then append the content (which will use the data passed to it), and then append the footer.

There are other ways to accomplish this. One way might be to load your header and footer into the $data which you pass to the main view (i.e. $data['header']=yourHeaderHereWink, and then in your main view you could simply
Code:
<?php echo $header ?>

I hope that helps; I'm still very new to CI myself.
#3

[eluser]Peter74[/eluser]
of course it help, txs
i was doing the second sugestion, only php, with my own functions and class, but this

$this->load->view('content', $data);

is my cuestion cuz, i have just one controller, then $data may content a whole page, in my case iam thinking in a member areas, with center tabs menu, and right menu, i have to practice your comment and see how it work.

Very txs for ur answer, help me alot




Theme © iAndrew 2016 - Forum software by © MyBB