Jump to content

Just wondering if this can be done


SmokingMan

Recommended Posts

I'm working on a site right now in which the only thing that changes from page to page is the main content. The header, footer, and navigation menu stay the same on every page. But I'm not using frames (hate them). Presently I use 'include' to pull in the content for each part of the page because I couldn't see coding the same thing into multiple pages. But I had a thought (a dangerous thing, I know). Rather than have multiple pages with all content being the same save for one, why not just have the one page and use a script of some sort to change the main content depending on the link clicked on by the user.What I'm wondering, and finally getting to, is can you use a variable in an 'include', and furthermore, can you use Javascript to pass that variable? Then, how would you go about getting that 'include' to refresh the content? Or is this something too involved that I really don't want to do? It works fine right now as it is by just reloading the entire page with the new content. As far as the user knows, the only thing changing is the main content. I'm just curious as to whether or not this can be done so as to make the site a little leaner by only having one page to load, the rest being only changing content.Am I making any sense here, or are these the ramblings of one with too much caffiene this morning?

Link to comment
Share on other sites

No. You can't alter that variable with JS and get the next page without reloading.But including the per-page data rather then the common one is possible.The only problem is that the GET variable might get too long at some point (exceed 256 characters, or whatever the limitation was). That's not applicable to small and middle size sites, so you should be OK.So, you can have

index.php?page=file

where "file" is the per page data. And the corresponding file

<html><!--Common HTML--><?php include($_GET['page']); ?><!--More common HTML--></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...