toolman Posted July 25, 2010 Share Posted July 25, 2010 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 More sharing options...
msaz87 Posted July 25, 2010 Share Posted July 25, 2010 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 More sharing options...
toolman Posted July 25, 2010 Author Share Posted July 25, 2010 Thank you very much! I will give it a go Link to comment https://forums.phpfreaks.com/topic/208860-how-would-i-do-this/#findComment-1091060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.