Login   Register  
PHP Classes
elePHPant
Icontem

index.php?page=home instead of welcome.php direct call

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Auto Ajax  >  All threads  >  index.php?page=home instead of welcome.php direct call  >  (Un) Subscribe thread alerts  
Subject:index.php?page=home instead of welcome.php direct call
Summary:Is this possible?
Messages:6
Author:Mariusz Bieniek
Date:2007-11-17 16:59:26
Update:2008-02-29 00:57:45
 

  1. index.php?page=home instead of welcome.php direct call   Reply  
Picture of Mariusz Bieniek
Mariusz Bieniek
2007-11-17 16:59:26
Hello Cesar,

ive downloaded and tested your class. Its wonderful. Thanks for your efforts and for doing it! Nice job!

I have an question. At the moment the files are called directly so for example welcome.php is called and then its inlcuding the site structure index.php. Would it be possible to allow to work it like this?:

links like this => index.php?page=home

index.php could have an area like this:
<?php
$files = array(
"home" => "home.php",
"about" => "about.php",
"copyleft" => "copyleft.php"
);

if($_GET['page'] == ""){
$_GET['page'] = "home";
}

if(isset($_GET['page']) && isset($files[$_GET['page']])){
include($files[$_GET['page']]);
} else {
echo "<strong>Sorry.</strong><br />Page not found.";
}
?>

Would that be also ok or do you want to allow it only the way it is at the moment? Is it realizable?

Regards
Mariusz




  2. Re: index.php?page=home instead of welcome.php direct call   Reply  
Picture of Cesar D. Rodas
Cesar D. Rodas
2007-11-17 22:44:52 - In reply to message 1 from Mariusz Bieniek
Hello,

I was analyzing how to implement your request. And the easiest way to implement is that "ajax sections" could handle "callback functions" and php files.
So, when the paremeter is a callback (as in this example), it will be executed, otherwise, it will included.

Example:
This example will work if you link go to the main page, in the example the main page is "index.php", and will work only with "index.php?foo=bar".

Also will work if you going directly to the file "welcome.php".

<?php
/* this is the page definition */
$ajax->add("bottom","bottom_handler");

function bottom_handler() {
//you must write here
//your method to page
//selection.
if ( found ) {
include(page);
} else {
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
}
}
?>

What do you think of my solution proposal?




--
Best regards

  3. Re: index.php?page=home instead of welcome.php direct call   Reply  
Picture of Mariusz Bieniek
Mariusz Bieniek
2007-11-18 00:35:54 - In reply to message 1 from Mariusz Bieniek
Wow, fast response. Thanks for your time Cesar.

Iam not such an expert as you are. If you think this is the best way to do it then it is :-)

Will you include it in your release or will this be just an individual solution here? Will it still work when javascript is disabled as in your org. class (very important if you ask me)?


  4. Re: index.php?page=home instead of welcome.php direct call   Reply  
Picture of Cesar D. Rodas
Cesar D. Rodas
2007-11-18 17:48:02 - In reply to message 3 from Mariusz Bieniek
The autoajax works with or without javascript. :-)

And I will include that solution, and also I'll include a solution with a URL Rewrite Engine (my last class) tomorrow, and that will hide the real file name and will avoid the use of $_GET, I think is better to use with a URL rewrite, what do u think?

  5. Re: index.php?page=home instead of welcome.php direct call   Reply  
Picture of Mariusz Bieniek
Mariusz Bieniek
2007-11-19 04:07:02 - In reply to message 4 from Cesar D. Rodas
I think this is a very nice enhancement your URL Rewrite Engine. If I would start today a new project I would use your solution (Auto Ajax with URL Rewrite Engine) :-).

At the moment I have already a bigger project running where I cant change URLīs for now. So I will try to include the ?page=welcome method and look how good it will work. Will you update this thread as soon as you manage to finish the changes?

Regards
Mariusz

  6. Re: index.php?page=home instead of welcome.php direct call   Reply  
Picture of larry pappas
larry pappas
2008-02-29 00:57:45 - In reply to message 4 from Cesar D. Rodas
Hi guy:

I need the link look like this


HI can you help me lilttle bit more please


http://domainname/reseller/mega.php
I want to be this link:
http://domainname/?x=reseller&?&plan=mega

please somebody help me


larry pappas