voidflower

I'm smart! Or not..

I’m making a new theme or layout for my fanlisting collective and I wanted those cool dynamic tabs! The ones where if you click the tab, the page shows up, and the tab is “selected” for the current page! Neat-o! It didn’t seem that difficult to do with PHP but it had its little hiccups, so to say.

At first, I tried just an if statement basically saying “if this is the current page, print ____”. So by using the $_SERVER['PHP_SELF'] variable, I tried that. Didn’t work! It seemed logical that it would, but alas, no dynamic tabs.

At this point, I’m wondering what else I need to do to make this work. The if thing seemed logical, but didn’t work. So I looked around on google and all the PHP dynamic tabs I saw had some sort of array of the actual page names. So I tried an array. Didn’t work. But I probably did that wrong. In the end, I just wrote a function where I manually wrote in the page name for the function’s parameters and then compared it to what the server thinks is the current page.

function pagename($name) {
$currpage = basename($_SERVER['SCRIPT_NAME']);
$name2 = $name .”.php”;
if ($currpage == $name2) {
print ” class=\”current\”";
}
}

Yay! It works! It took me two hours to do 7 lines of code, but it works! All PHP pros out there are probably laughing at me. :\
That’s my story for the day :P

Comments

3 responses to I'm smart! Or not..

  • If you ever find out how to do that, let me know, because I’d be very interested. (I”m gemtiger on DMB, by the way, HIIII :D)

    Cat on December 14, 2006 at 04:18 (1326 days ago)

  • well i’ve replied
    http://dodosmb.com/viewthread.php?tid=8468

    dodo on December 16, 2006 at 14:36 (1323 days ago)

  • Thank you Dodo! You’re so smart :D

    Bekki on December 17, 2006 at 12:44 (1322 days ago)

Add a Comment

You can't! They're closed! >:D