Need some HTML coding help. Thanks

Discussion in 'Programming' started by Nystul, Nov 23, 2007.

  1. #1
    How do i create "A" to show on homepage only, and all other pages to be showing "B" ?

    Right now i got this to show up A on home page, but I have no idea to make B to show up on all others.




    <?php /* If this is the frontpage */ if ( is_home() ) { ?>

    Show "A"

    <?php } ?>



    Thanks for the help!
     
    Nystul, Nov 23, 2007 IP
  2. Troytime

    Troytime Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?
    if(is_home))
    echo "A";
    else echo "B";
    ?>
     
    Troytime, Nov 23, 2007 IP
  3. gopher292

    gopher292 Peon

    Messages:
    64
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Troy, that only works if is_home() is setup as a valid function.

    And you don't have curly braces

    <?
    if($_SERVER['PHP_SELF']='index.php') {
    echo "A";
    } else {
    echo "B";
    }
    ?>

    (Edit:) Replace index.php with your homepage file, if it's different.
     
    gopher292, Nov 23, 2007 IP
  4. Nystul

    Nystul Well-Known Member

    Messages:
    3,077
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    175
    #4
    Great ! Thanks for the help. I put it to try once i get a chance tonight!
     
    Nystul, Nov 23, 2007 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    $_SERVER['PHP_SELF'] has some issues depending on how you are passing your vars and the document directory structure - I'd suggest using:

    basename($_SERVER['SCRIPT_FILENAME'])

    instead.
     
    deathshadow, Nov 24, 2007 IP