• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Load Header and Footer

#1
[eluser]Unknown[/eluser]
I would do something similar to this:

Code:
<div id="topo">
&lt;?php
@include "topo/banner.php";
?&gt;
</div>&lt;!--fim de topo--&gt;
<div id="corpo">
    <div id="painel">
        <div id="menu">
            <div id="menulista">
                <ul>
                    <li><a href="index.php">Home</a></li>
                    <li><a href="index.php?menu=link1">Link 1</a></li>
                    <li><a href="index.php?menu=link2">Link 2</a></li>
                    <li><a href="index.php?menu=link3">Link 3</a></li>                                    
                    <li><a href="index.php?menu=link4">Link 4</a></li>
                    <li><a href="index.php?menu=link5">Link 5</a></li>
                    <li><a href="index.php?menu=link6">Link 6</a></li>
                    <li><a href="index.php?menu=link7">Link 7</a></li>                                                
                </ul>
            </div>&lt;!--fim de menulista--&gt;
        </div>&lt;!--fim de menu--&gt;                    
    </div>&lt;!--fim de painel--&gt;
    <div id="principal">
    &lt;?php
    if (isset($_GET['menu'])){
        switch ($_GET['menu']){
            case linkum:
                @include ("linkum.php");
                break;
            case linkdois:
                @include ("linkdois.php");
                break;
            case linktres:
                @include ("linktres.php");
                break;
            case linkquatro:
                @include ("linkquatro.php");
                break;
            case linkcinco:
                   @include ("linkcinco.php");
                break;
            case linkseis:
                   @include ("linkseis.php");
                break;
            case linksete:
                @include ("linksete.php");
                break;                                                                
        }
    }
    else {
        @include ("home.php");
    }
    ?&gt;
    </div>&lt;!--fim de principal--&gt;
    <div id="colunalateral">                    
    </div>&lt;!--fim de colunalateral--&gt;
</div>&lt;!--fim de corpo--&gt;
<div id="rodape">
&lt;?php
@include "rodape.php";
?&gt;
</div>&lt;!--fim de rodape--&gt;

I can load from the header and footer views and central part to do the layout.
In the code above is done without using the CI, could do this in, or has to be done differently?

#2
[eluser]manilodisan[/eluser]
It's not bad as long as you don't repeat code such as that switch statement in multiple parts of your application. However, I hate seeing so much php code inside the views (but this is me, nothing wrong to it). I would rather make a function and set the menu part slightly different:

Code:
<div id="topo">
&lt;?php
@include "topo/banner.php";
?&gt;
</div>&lt;!--fim de topo--&gt;
<div id="corpo">
    <div id="painel">
        <div id="menu">
            <div id="menulista">
                <ul>
                    <li><a href="index.php">Home</a></li>
                    <li><a href="index.php?menu=link1">Link 1</a></li>
                    <li><a href="index.php?menu=link2">Link 2</a></li>
                    <li><a href="index.php?menu=link3">Link 3</a></li>                                    
                    <li><a href="index.php?menu=link4">Link 4</a></li>
                    <li><a href="index.php?menu=link5">Link 5</a></li>
                    <li><a href="index.php?menu=link6">Link 6</a></li>
                    <li><a href="index.php?menu=link7">Link 7</a></li>                                                
                </ul>
            </div>&lt;!--fim de menulista--&gt;
        </div>&lt;!--fim de menu--&gt;                    
    </div>&lt;!--fim de painel--&gt;
    <div id="principal">
    &lt;?= set_menu () ?&gt;
    </div>&lt;!--fim de principal--&gt;
    <div id="colunalateral">                    
    </div>&lt;!--fim de colunalateral--&gt;
</div>&lt;!--fim de corpo--&gt;
<div id="rodape">
&lt;?php
@include "rodape.php";
?&gt;
</div>&lt;!--fim de rodape--&gt;

Code:
function set_menu ()
{
    if (isset($_GET['menu'])){
        switch ($_GET['menu']){
            case linkum:
                @include ("linkum.php");
                break;
            case linkdois:
                @include ("linkdois.php");
                break;
            case linktres:
                @include ("linktres.php");
                break;
            case linkquatro:
                @include ("linkquatro.php");
                break;
            case linkcinco:
                   @include ("linkcinco.php");
                break;
            case linkseis:
                   @include ("linkseis.php");
                break;
            case linksete:
                @include ("linksete.php");
                break;                                                                
        }
    }
    else {
        @include ("home.php");
    }
}

Also, there's an interesting thread running in this forum, you might wanna check it out:

http://ellislab.com/forums/viewthread/100620/


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.