Page 1 of 1

Seperating content from design

Posted: Mon Dec 28, 2009 3:36 am
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

Re: Seperating content from design

Posted: Mon Dec 28, 2009 4:04 am
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

Re: Seperating content from design

Posted: Mon Dec 28, 2009 5:03 am
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