Pages
Pages are loaded dynamically via url parts
Martivia consists of css,func,js,view folders and index.php, db_open.php, db_close.php. View folder consists of inc and pages folders.
For beautiful url we chunck Request_URI as $p1,$p2,$p3,$p4 for the parts of the url /$p1/$p2/$p3 ...
The page routing is driven by $_GET method or by redirecting all request to index.php and chunking url by "/" parts for beautiful url.
For Example: https://example.com?page=login or https://example.com/login
Example:
$url = $_SERVER['REQUEST_URI']??"";
$path = $_SERVER['REDIRECT_URL']??"";
$url=str_replace("/?","?",$url);
$url=str_replace("?","/?",$url);
$parts = explode('/',$url);
array_shift($parts);
$i=1;
foreach($parts as $part){
$p="p".$i;
$$p=mysqli_real_escape_string($con,$part);
if(strpos($$p,"?")===0){
$$p="";
}
$i++;
}
if($p1==""){
$p="home";
}else{
$p=$p1;
}
include("view/inc/head.php");
include("view/pages/".$p.".php");
include("view/inc/foot.php");
Updated almost 2 years ago