Jump to content

$_GET without static caseswitch file?


suntracker

Recommended Posts

I am very new to PHP and took a look at the FAQ presented here: http://www.phpfreaks.com/forums/index.php/topic,31047.0.html

The first topic in there (regarding the dynamic URL's) is what I believe to be my problem/issue.

 

Here are my questions:

 

1) That thread is pretty old (2004) -- If I have several static elements on a page (like a menu / sidebar / footer / etc) but wish to load content into a center column (all links followed will have PHP load the new page into that div), is using $_GET still the preferred way to do this?

 

2) If YES to #1, Google Analytics doesn't like these dynamic addresses. Should the above method be used and then do I need to translate those addresses to appear static?

 

3) If YES to #1, is using a static caseswitch.php file the only way to do this? New pages will be generated all the time... it would be really a pain to have to constantly update that file. Would it be better to somehow query a database?

 

4) If NO to #1, what is the currently preferred method to switch content on a page?

 

Thank you for any assistance,

-Austin

Link to comment
https://forums.phpfreaks.com/topic/108445-_get-without-static-caseswitch-file/
Share on other sites

1) I do it that way.

 

2) It's best to use htaccess if you know the number of varialbes that are going to be posted to each page, if not, you can have 2 /'s in the url. ie blahblah.com/egpagename/number-4434,change-yes/

 

which will transfer to blahblah.com/?pagename=egpagename&vars=number-4434,change-yes

 

which can be manipulated to form the normal URLs that you are using. I'll send you the script for htaccess if you're running apahce.

 

3) I think it's by far the easiest. I don't know what you mean about the problem, please make it more clear.

Thanks.

 

For the caseswitch file, what I mean is: are there any more elegant ways of doing this? I'm aiming to allow for users to add new pages. If 1000 pages get added, doesn't that require 1000 case statements in the switch block? That seems excessive...

check out this post I made about the "templating" system I use.

 

http://www.phpfreaks.com/forums/index.php/topic,197740.msg892510.html#msg892510

 

It is uses includes and a custom function to "wrap" a page inside the main layout page.

 

Makes it nice because I can simply code this for a new page.

 

<?php 
$page_title = 'This pages title';
include($_SERVER['DOCUMENT_ROOT'].'/header.php');

echo 'This is my page content';

footer();

?>

I suppose a mysql query could be used, and may be the easiest way of doing this, you can also put username, date made fields into this, and it would be make a search page easier if you plan to implement that.

 

OR

 

you could place all of the pages into a single directory and then use some file functions which i can never remember to list them into an array, which would have less functionality.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.