Jump to content

Need help linking in a template with a variable and include


mynameisham

Recommended Posts

<?php $page="main"; ?>

<div id="page" align="center">

    <div id="header">

    <img src="images/header.jpg" border="0" usemap="#Map" />

      <map name="Map">

      <area shape="rect" coords="0,0,800,93" href="index.php?page=main">

<area shape="rect" coords="57,113,203,161" href="index.php?page=gallery">

<area shape="rect" coords="214,112,419,155" href="index.php?page=reel">

<area shape="rect" coords="428,116,580,160" href="index.php?page=resume">

<area shape="rect" coords="593,112,746,152" href="index.php?page=contact">

</map>

</div>

<div id="middle"><br /><br />

<div id="body">

<?php @ require_once ("$page.htm"); ?>

</div>

    </div>

<div id="footer" align="left"> 

</div>

</div>

 

This is the code I'm using to attempt to make the links in the header open a different page with include. At first the code would just stop rendering right before the require tag, but after I added in the first php code to define the variable $page as main at first, it would at least render the entire page correctly. Now, however none of the links work. They change the address in the address bar to index.php?page=gallery, but the div never changes to the gallery page. Any ideas on what I might be doing wrong?

Link to comment
Share on other sites

Sorry for the double post, but I meant to include that the links have never worked. The only way the php displays the site I want it to is if I hardcode a value for the variable into the site somewhere, which then takes away from the modular nature I'm going for. I took out the hardcoded $page="main" tag, because I knew that was just keeping my links from working, but it still didn't fix anything. And once my links are working, how do I give the $page variable a default value of "main" so that it will load the main site on the first visit?

 

I know the reason the links don't work right is because the code stops when it's looking for a value for $page on that initial load, and it returns a value of nothing. Thus, the html translation ends there and the code my links relied on to function isn't even on the page. But if I hardcode a value into the site, when the links reopon index.php, the value of $page is overwritten by the hardcode. I'm at a catch 22 it seems!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.