• 0

[PHP]Showing text on a certain page


Question

Basically i have a site

http://danbriant.com/

Now i have a page on there called

http://danbriant.com/site/photography.php

Now the links under Photography i only want them to show when that page is loaded.

The navigation menu is a php include to a php file just with html links in it.

Link to comment
https://www.neowin.net/forum/topic/666832-phpshowing-text-on-a-certain-page/
Share on other sites

3 answers to this question

Recommended Posts

  • 0

it's nothing fancy what i got

all pages have a php include to navigation.php

then inside navigation.php

<div class="sticky">
  <div class="title">Navigation</div>
  <ul>
	<li><a href="index.php">Home</a></li>
  </ul>
  <ul>
	<li><a href="blog/">Blog</a></li>
  </ul>
  <ul>
	<li><a href="photography.php">Photography</a></li><br />
	- Studio<br />
	- Location<br />
	- Personal<br />
	- Events<br />
	- Equipment<br />
  </ul>
  <ul>
	<li><a href="about.php">About Me</a></li>
  </ul>
  <ul>
	<li><a href="timevault.php">Time Vault</a></li>
  </ul>
</div>

Now the links under photography title i want them to only show when photography.php page is loaded and ofcourse i want them to also show while your inside any of the other pages that relate to photography, so eg studio.php

  • 0

Alright well this is a slightly ugly way of doing things but for the sake of keeping it simple, try this...

<div class="sticky">
		<div class="title">Navigation</div>
		<ul>
		  <li><a href="index.php">Home</a></li>
		</ul>
		<ul>
		  <li><a href="blog/">Blog</a></li>
		</ul>
		<ul>
		  <li><a href="photography.php">Photography</a></li>
	  <?php
	  if ($_SERVER["PHP_SELF"] == "/site/photography.php") {

	  echo '<br />- Studio<br />

		  - Location<br />

		  - Personal<br />

		  - Events<br />

		  - Equipment<br />
	';
	  }
	  ?>
		</ul>
		<ul>
		  <li><a href="about.php">About Me</a></li>
		</ul>
		<ul>
		  <li><a href="timevault.php">Time Vault</a></li>
		</ul>
	  </div>

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

  • Recent Achievements

    • One Year In
      Console General earned a badge
      One Year In
    • One Year In
      Twozo Technologies earned a badge
      One Year In
    • One Month Later
      Twozo Technologies earned a badge
      One Month Later
    • Week One Done
      Twozo Technologies earned a badge
      Week One Done
    • Veteran
      branfont went up a rank
      Veteran
  • Popular Contributors

    1. 1
      +primortal
      503
    2. 2
      +Edouard
      194
    3. 3
      PsYcHoKiLLa
      127
    4. 4
      Steven P.
      88
    5. 5
      neufuse
      71
  • Tell a friend

    Love Neowin? Tell a friend!