Welcome Guest, Not a member yet? Register   Sign In
a real life project with ci. THE BEST STRUCTURE= header-footer-sidebar, where to include ....
#1

[eluser]artlover[/eluser]
Hi friends,

days and days I researched at internet for a ci project directory tutorial, but could not find any Sad

I wonder how to build the best structure.
= Where to keep header.php, footer.php, sidebar.php ... ?
= where to include them into page?
= how to include them into page?
= ...

to sum up, how to start the first project with real example?

all tutorials on internet shows how to write "hello world!" etc... but when I want to build a real life project, I dont know where to start, how to do things... Sad

any help?

I appreciate, thanks a lot.
#2

[eluser]Maglok[/eluser]
Well header/footer/sidebar should just be more views in CI. Basically you can call a view from a view like this:

Code:
<?php $this->load->view('menu');?>

Making it rather easy to include them.

As for a example implementation with open sourcecode, I dunno.
#3

[eluser]Thorpe Obazee[/eluser]
[quote author="Maglok" date="1245768465"]Well header/footer/sidebar should just be more views in CI. Basically you can call a view from a view like this:

Code:
<?php $this->load->view('menu');?>

Making it rather easy to include them.

As for a example implementation with open sourcecode, I dunno.[/quote]

bambooinvoice
#4

[eluser]Brain Coder[/eluser]
Quote:= Where to keep header.php, footer.php, sidebar.php ... ?
= where to include them into page?
= how to include them into page?

1- keep it in the viewer directory
2- include what you want like this

$this->load->view('footer');

and i suggest to use something like this in your controller

$data['main'] = 'admin_pages_create';
$this->load->view('template',$data);

the admin_pages_create is a page in your viewer directory

and you can loading it by using

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

in your template view
#5

[eluser]artlover[/eluser]
bambooinvoice[/quote]

thanks for the link. yes it is good way to see how things had been structured Smile the only thing is, which it would be a smaller project example. it is a bit too much complicated. but i see good point in that Wink
#6

[eluser]artlover[/eluser]
[quote author="Brain Coder" date="1245768808"]
Quote:= Where to keep header.php, footer.php, sidebar.php ... ?
= where to include them into page?
= how to include them into page?


the admin_pages_create is a page in your viewer directory

and you can loading it by using

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

in your template view[/quote]


this admin_pages_create thing confused me :-S
#7

[eluser]Maglok[/eluser]
It is an example, basically 'admin_pages_create' can be replaced by your view. Footer or header for example.
#8

[eluser]artlover[/eluser]
I have a static website work, I have already completed. but I want to change structure to CI... I hope I can manage with your helps...
#9

[eluser]Brain Coder[/eluser]
[quote author="Maglok" date="1245769524"]It is an example, basically 'admin_pages_create' can be replaced by your view. Footer or header for example.[/quote]

thats right this page is just for example

I will let you see something

//Controller index function

Code:
function index(){
    $data['title'] = "Control panel";
    $data['main'] = 'admin_home';
    $this->load->helper(array('form','security'));
    $data['last_notice'] = $this->MSet->getLastNotice();
    $this->load->vars($data);
    $this->load->view('dashboard',$data);
  }

//viewer . admin_home.php page
Code:
<table border="0" width="100%" dir="rtl" cellspacing="0" cellpadding="0" align="center" >
    <tr>
        <td align="center">
<div align="center" id="page">
&lt;?php


echo form_open('admin/dashboard/create');
echo "<p><label for='long'>Notice</label><br/>";
$data = array('name'=>'notice','id'=>'long','rows'=>5, 'cols'=>'40','value' => $last_notice['notice']);
echo "<p align=center>" . form_textarea($data) ."</p>";
echo form_submit('submit','Save');
echo form_close();

?&gt;
</div>

        </td>
    </tr>
</table>

//view template dashboard.php
Code:
<div id="main"  >
        
        &lt;?php $this->load->view('admin/'.$main);?&gt;

    </div>

Just like this Smile
#10

[eluser]artlover[/eluser]
thanks @BrainCoder for great example! I appreciate you to give time for that.

so in the example you created an another folder, under system/application, named viewer/ and dashboard is the actually main view file.

Do I need model file for static pages as well at ci? my current project is static website, I only have dynamic contact email form. thats it. so I guess i don't have to create model files for each pages like home_model.php, aboutus_model.php ...?




Theme © iAndrew 2016 - Forum software by © MyBB