Page 1 of 1

Changing navigation, whatcha guys think?

Posted: Thu Aug 29, 2002 5:48 pm
by JPlush76
ok here is my dilema, I have a website and on the main page it has two choices of main pages to go to.

Code: Select all

OPTION PAGE 1
MAIN PAGE - 
                     OPTION PAGE 2
well when they go either page the navigation and footer should be set for that page. the pages all have the same content but the nav and footer need to be different for each "OPTION PAGE"

So what I was going to do is use the magic of sessions and create a flag so if they click on option page 1 the flag gets set with what nav they should see and all the pages they click on after that will check that flag and display the nav accordingly.

I was going to make some functions to do this check IE:

Code: Select all

CheckHeaderNav($flag)

Code: Select all

CheckFooterNav($flag)
then I was thinking this could be a good opportunity to get a better grip on OOP and do it in OOP.

What do you guys think? I can do it proceedurley no prob, oop will give me a challange but I'm just seeing if I'm missing anything, because it seems really simple to do. I just don't want to finish it and find out I should have set this up a different way, because its like 100 pages :)

thanks!

Posted: Fri Aug 30, 2002 10:40 am
by nielsene
Hmm, if I were using OOP here I'ld do something I'ld probably make an abstract "Template" base class and then subclass the two versions from it.

Something like

Code: Select all

class Template
{
       function printHeader()
       {
           return false;
       }
       function printFooter()
       {
            return false;
       }
}
class BroadbandTemplate extends Template
{
      function printHeader()
      { // lots of crazy graphics stuff, whatever else
      }
      function printFooter()
      {// more of the craziness}
}
class DialupTemplate extends Template
{
      function printHeader()
      { echo "<h1>Hi</h1>";}
      function printFooter()
      { echo "bye";}
}

$classname = $GETї"flag"] ? "BroadbandTemplate" :"DialupTemplate";
$template = new $classname();
$template->printHeader();
// content
$template->printFooter();
Likely you'll need to add some variables to the functions/classes, but this might give you a start.

(Editted Code->PHP