Seperating content from design

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
KostaKondra
Forum Newbie
Posts: 16
Joined: Thu Nov 19, 2009 8:26 am

Seperating content from design

Post by KostaKondra »

So this is what I want to do.

I want to be able to have my left navigation bar in another file.

So let's say you have

<div id="navigation">
#include "leftbar.php"
</div>

and... leftbar.php would include the following:

<a href="link1.html">Link 1</a>
<a href="link2.html">Link 2</a>
etc. etc.

Do you understand?

So that way let's say I decide to change a menu item I don't have to go through and change every page on my website. Can anyone help?

Regards
jeetu2009
Forum Newbie
Posts: 2
Joined: Sun Dec 27, 2009 11:28 am

Re: Seperating content from design

Post by jeetu2009 »

you can do this with two step

step 1 : create left.php
<a href="index.html?alt=link1">Link 1</a>
<a href="index.html?alt=Link2">Link2</a>
with this above code

step 2:index.php u have to include:
<?php
if(isset($_GET['alt']))
{
if($_GET['alt']=="link1")
{
include('Link1');
}
if($_GET['alt']=="Link2")
{
include('Link2');
}
}


try this
KostaKondra
Forum Newbie
Posts: 16
Joined: Thu Nov 19, 2009 8:26 am

Re: Seperating content from design

Post by KostaKondra »

jeetu2009 wrote:you can do this with two step

step 1 : create left.php
<a href="index.html?alt=link1">Link 1</a>
<a href="index.html?alt=Link2">Link2</a>
with this above code

step 2:index.php u have to include:
<?php
if(isset($_GET['alt']))
{
if($_GET['alt']=="link1")
{
include('Link1');
}
if($_GET['alt']=="Link2")
{
include('Link2');
}
}


try this
Hi thanks for the quick reply but why would you need that conditional statement? And why would left.php be linking to two
index.php pages? When you say include('Link2') would I have to make a Link2.php. Help!

By the way I'm not stupid with coding, just not understanding those particular functions. Feel free to direct me to further reading.

Regards
Post Reply