+upd routes.json + router.page to have uri arguments (or any data separated by slashes in the array $_GET['uri'])
This commit is contained in:
parent
c8871cbab4
commit
7484bea239
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
public function __construct($url){
|
||||
$this->pagename = $url['page'];
|
||||
$this->uri = $url['uri'];
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,10 +23,22 @@
|
|||
*
|
||||
*/
|
||||
public function load(){
|
||||
if( file_exists(__PUBLIC__."/page/".$this->pagename.".php") )
|
||||
include __PUBLIC__."/page/".$this->pagename.".php";
|
||||
else
|
||||
echo "page not found";
|
||||
|
||||
/* (1) Build page file name */
|
||||
$page_fname = __PUBLIC__."/page/".$this->pagename.".php";
|
||||
|
||||
/* (2) If page does not exist -> 404 */
|
||||
if( !file_exists($page_fname) ){
|
||||
http_response_code(404);
|
||||
die('Page not found');
|
||||
}
|
||||
|
||||
/* (3) Set URI arguments */
|
||||
$_GET['uri'] = explode('/', $this->uri);
|
||||
|
||||
/* (4) Load page */
|
||||
include __PUBLIC__."/page/".$this->pagename.".php";
|
||||
|
||||
}
|
||||
|
||||
/* POST-CALL
|
||||
|
|
|
@ -20,11 +20,12 @@
|
|||
}
|
||||
},
|
||||
|
||||
"/{page}/": {
|
||||
"/{page}/{uri}": {
|
||||
"methods": ["GET"],
|
||||
"controller": "page:load",
|
||||
"arguments": {
|
||||
"page": "[a-z]+"
|
||||
"page": "[a-z]+",
|
||||
"uri": ".*"
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue