Jump to content

How would I do this?


toolman

Recommended Posts

Hi,

 

I have a template with a main content area and a right column.

 

The main content area echos my page content by using:

<?php echo $template_content; ?>

 

The right hand side will remain the same throughout the template, except, I want to have a "related links" section on the top of the right section.  It will only have a few links, but it will need to change on certain pages.

 

I was wondering if I could use an "if" statement to echo content on this right hand side if I define these links in the external pages?

 

Any advice would be great.

Thanks

Link to comment
https://forums.phpfreaks.com/topic/208860-how-would-i-do-this/
Share on other sites

Have some sort of variable defining what page you're on:

 

$page_title = "home";

 

Then with the links, include an external links page:

include('links.php');

 

and on that page, you can do a switch:

switch($page_title) {

   case "home":
      echo "link 1<br/>";
      echo "link 2<br/>";
      break;

   case "contact":
      echo "link 1<br/>";
      echo "link 2<br/>";
      break;

   default: // if none of the titles match, these show by default
      echo "link 1<br/>";
      echo "link 2<br/>";
      break;

}

 

Just make sure the $page_title variable is defined before that page is included.

Link to comment
https://forums.phpfreaks.com/topic/208860-how-would-i-do-this/#findComment-1091025
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.