Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
nooge
May 1, 2009

Hmmm I guess I'll try this here because it's more centered around JS.
So I have a single PHP document that consolidates my head, my tool menubar, page content and a footer. My overall goal is to be able to have the active page on the menubar to be highlighted and the link disabled without having to stray from my original idea of organizing the pages. I figure declaring a variable somewhere in the clusterfuck to identify what page I am on then have Javascript tell the header.php (where the menubar is) to do the dirty work.

The issue I have to finding a place to declare the variable. Here is a general idea of what's going on in the main page of index.php:
code:
<?php include "head.php"; ?> 
<?php include "header.php"; ?> 
<?php include "index_content.php"; ?> 
<?php include "footer.php"; ?>
After that, it loads those pages and voila.

All the Javascript action is going to be contained in header.php, so I need a good place to declare a single varaible:
code:
var site_id = "index";
My first thought would be to create another page solely for the use of declaring it, but that seems retarded and I know there must be a better way - such as doing it in my index.php. Any quick way or doing it or a resource to guide me?

tl;dr edit:
I guess I really just would like to know an easy way to declare a variable in my index.php without breaking everything and have it read into the header.php.

nooge fucked around with this message at 15:31 on May 4, 2009

Adbot
ADBOT LOVES YOU

nooge
May 1, 2009

Supervillin posted:

Definitely a PHP question, not JS, but here you go:

php:
<?
    // in index.php
    $page = 'index';
    include('header.php';
?>
Voila, $page is available inside header.php.

Awesome that worked perfectly. I'm sure the 2nd method works great too but I'm not entirely fluent in PHP and don't like copy and pasting without fully understanding. I'll sit down tonight and decipher what you did. Thanks a lot!

nooge
May 1, 2009

Another small question... after I used that code it looks and works great - except it lags a bit when loading the picture compared to those around it even though it it is the same size. Any way to speed up the process or am I stuck with that small (.25 second) lag?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply