Got a php/css question....

Discussion in 'Software' started by ICeMaN, Jul 24, 2004.

  1. ICeMaN

    ICeMaN Master Sergeant

    I just installed the same Arcade hack that MajorGeeks here uses on my forum, but it uses a portal that uses the vBulletin navbar. When you hit the link from the front page it gives you a 404 because the index for the portal is outside of the forum directory. It works just fine from inside the forum... so how would I rewrite the tag where it works with both the portal and forum? I'm pretty sure it would have to be a conditional statement.. but I'm lost. I've been banging my head against this for the last two hours LOL

    Any help or idea's you guys have would be great :)
     
  2. goldfish

    goldfish Lt. Sushi.DC

    You can do this with the $_SERVER['DOCUMENT_ROOT'] server variable. This gives you the current directory of the executing document.
    PHP:
    <?php

    $inforum 
    "forum";
    $inforumlink "arcade.php";
    $outforumlik "/forum/arcade.php";

    if (
    $patharrayexplode($_SERVER['PATH_TRANSLATED'])) {
    if (
    $patharray[0] == $inforum) {
    echo 
    "<a href='$inforumlink'>Arcade</a>";
    }
    else {
    echo 
    "<a href='$outforumlink'>Arcade</a>";
    }
    ?>
    But now thinking about it, thats COMPLETLEY un-nececary, because all you need to do is make it an absolute path!!!!! i.e. <a href="http://www.example.com/forum/arcade.php"> ! :eek: How Dumb of me!!
     
  3. Radiofool

    Radiofool Private First Class

    :eek:

    I have enough trouble with English, let alone PHP or SSC or DS9 or whatever.

    Wow.
     
  4. goldfish

    goldfish Lt. Sushi.DC

    If anyone wants the completley useless code, here it is, and it works too.
    PHP:

    $inforum 
    "a";

    $patharray explode("/"$_SERVER['PHP_SELF']);
    if (
    $patharray['1'] == $inforum) {
    echo 
    "<a href='arcade.php'>Arcade</a>";
    }
    else {
    echo 
    "<a href='forum/arcade.php'>Arcade</a>";
    }

    $inforum is the name of the directory the forum is in.

    It's completley pointless as you can do all of this in one line of HTML... in fact the only good reason there is to use it is if you happened to change domain names a lot. And even then you can use a small PHP call for the domain name to make an absolute path.
     
  5. ICeMaN

    ICeMaN Master Sergeant

    Blink.

    OK, great... so I just insert that over the tag that's giving me trouble?
     
  6. ICeMaN

    ICeMaN Master Sergeant

    Hehe I got it working...

    Took me a minute, but I was looking at how the other links were structured and basically copied the format. I changed this:
    Code:
    <td class="vbmenu_control"><a href="arcade.php?$session[sessionurl]">Arcade</a></td>
    to this:
    Code:
    <td class="vbmenu_control"><a href="$vboptions[bburl]/arcade.php?$session[sessionurl]">Arcade</a></td>
    Next big thing is gonna be a module block on the front page showing the top ten scores :)
     
  7. goldfish

    goldfish Lt. Sushi.DC

    Ah, thats cool. Didn't realise that there was a $vboptions array obviously as I don't have the code!... that would have made things a whole lot easier :)
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds