brian914 Posted August 15, 2009 Share Posted August 15, 2009 I pretty much know no php, but am redesigning a site that was built in php. The php on the site is super simple and I am trying to add to it a little bit. All the pages in this site have their own page, meaning my about page has an about.php, home has index.php, etc. I am trying to set my navigation so when I am on that page for the navigation to show the page you are on. So, I would like to do something like this: On each of the pages, I would set my page variable just before the include tag of the navigation, something like this: <?php $thisPage = 'deathValley'; ?> Then in the navigation php file, I would test for my page like so? But I guess you can't use html with php like that? How would I write this? <?php <ul> <li> {if mypageVariable == deathValley} <a id="uberlink2" href="#">DeathValley</a> {if:else} <a href="bio_deathvalley.php">DeathValley</a> {/if} </li> </ul> ?> Also, is there a way to test for the url of the page, or something else? That way I would not have to set the variable on each page? Thanks a lot for any help with this! Quote Link to comment https://forums.phpfreaks.com/topic/170434-newbie-help-please/ Share on other sites More sharing options...
taquitosensei Posted August 15, 2009 Share Posted August 15, 2009 if I understand what you're asking this would do it <ul> <li> <?php echo ($mypageVariable=="deathValue")?"<a id='uberlink2' href='#'>DeathValley</a>":"<a href='bio_deathvalley.php'>DeathValley</a>"; ?> </li> </ul> Quote Link to comment https://forums.phpfreaks.com/topic/170434-newbie-help-please/#findComment-899035 Share on other sites More sharing options...
brian914 Posted August 15, 2009 Author Share Posted August 15, 2009 That gives me the following error. Fatal error: Call to undefined function: php�echo�() in /home/content/s/w/1/sw1tchbl4de/html/stage/v1/sidenav_bios.php on line 2 Quote Link to comment https://forums.phpfreaks.com/topic/170434-newbie-help-please/#findComment-899045 Share on other sites More sharing options...
play_ Posted August 15, 2009 Share Posted August 15, 2009 Then something else is wrong somewhere. Show full code Quote Link to comment https://forums.phpfreaks.com/topic/170434-newbie-help-please/#findComment-899064 Share on other sites More sharing options...
taquitosensei Posted August 15, 2009 Share Posted August 15, 2009 what version of php are you using? Quote Link to comment https://forums.phpfreaks.com/topic/170434-newbie-help-please/#findComment-899071 Share on other sites More sharing options...
oni-kun Posted August 15, 2009 Share Posted August 15, 2009 Your navigation is very confusing. You may want to set up index.php to use GET for navigation. Menu.php could be separate but included. index.php?page=about index.php?page=bio index.php?page=DeathValley That's what most sites do. In menu.php or your page if you want.. <?php <ul> <li> if($_GET['page']=="DeathValley") { echo '<a id="uberlink2" href="?page=DeathValley">DeathValley</a>'; }elseif($_GET['page']=='About'){ echo '<a href="?page=About">About</a>'; </li> </ul> ?> Seems like a much more viable option.. but I have no clue what you're doing, your navi is very obscure, your links aren't making any sense to me.. Quote Link to comment https://forums.phpfreaks.com/topic/170434-newbie-help-please/#findComment-899079 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.