How to get Current Page URL in via PHP?

<?php
function curPageURL() {
$pageURL = ‘http’;
if ($_SERVER[“HTTPS”] == “on”) {$pageURL .= “s”;}
$pageURL .= “://”;
if ($_SERVER[“SERVER_PORT”] != “80”) {
$pageURL .= $_SERVER[“SERVER_NAME”].”:”.$_SERVER[“SERVER_PORT”].$_SERVER[“REQUEST_URI”];
} else {
$pageURL .= $_SERVER[“SERVER_NAME”].$_SERVER[“REQUEST_URI”];
}
return $pageURL;
}

$url =  curPageURL();

//print_r(parse_url($url));

$URLpath = parse_url($url, PHP_URL_PATH);

$langPathAraay = explode(“/”, $URLpath);
$langPath = $langPathAraay[1];
//echo $langPath;

if($langPath == ‘agd_nl’){
//echo “here”;
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(108)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
else if($langPath==”agd_be”){
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(98)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
else if($langPath==”agd_befr”){
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(98)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
else if($langPath==”agb_de”){
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(105)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
else if($langPath==”agb_fr”){
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(106)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
else if($langPath==”agb_gb”){
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(107)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
else{
echo $this->getLayout()->createBlock(‘catalog/product_list’)->setRowCount(1)->setCategoryId(108)->setTemplate(‘catalog/product/list.phtml’)->toHtml();
}
?>

© 2020 Spirituality