Jump to content

Only specific links on a specific page


johnwinch42

Recommended Posts

Hello,

 

I would like to know how to proceed to only have specific links to show on a specific page (index.php  for example)

The links would be in my footer and would only show up on my homepage.

 

How can I do that?

 

Thanks for your answers,

 

Best regards,

Link to comment
https://forums.phpfreaks.com/topic/285899-only-specific-links-on-a-specific-page/
Share on other sites

Thanks you very much!

 

For the else I don't want to show anything on the other pages, would it be something like this?

 

<?php

    
if( $_SERVER['PHP_SELF'] == '/index.php' )
    {
        print '<a href="page2.php">Go to page 2</a>';    
    
}
    else
    {
        print ' ';    
    
}

?>

For the else I don't want to show anything on the other pages, would it be something like this?

 

If you don't want anything to show up, you don't need the else. The links will only show up when the if conditions are met.

 

Also note that you could use a switch for multiple pages:

 

<?php
switch($_SERVER['PHP_SELF']) {
     case '/index.php':
          print '<a href="page2.php">Go to page 2</a>';
          break;
     case '/page2.php':
          print '<a href="index.php">Go Home</a>';
          break;
}
?>

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.