Jump to content

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,

Edited by johnwinch42
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;
}
?>
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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