I have a class to change urls from Opencart. There's array of urls and their new values. My problem is I'd like to get those urls and values from mySQL database.
Original array is something as this:
I tried to do it this way:PHP Code:var $pages = array('contact' => 'common/home', 'search' => 'product/search', ...);
and inside class:PHP Code:while ($row = mysql_fetch_array($result)) {
$pages[] = array($row['route_seo_url'] => $row['route_old_url']);
}
but it doesn't work.PHP Code:var $pages = array();
This is whole original code:
Any suggestions will be appreciated.PHP Code:class ControllerCommonRoute extends Controller {
var $pages = array('contact' => 'common/home', 'search' => 'product/search', ...);
public function check() {
$uri = substr(str_replace(strrchr($this->request->server['REQUEST_URI'], '?'), '', $this->request->server['REQUEST_URI']),1 );
$uri = (substr($uri, -1)=='/')? $uri = substr($uri, 0, strrpos($uri, '/')) : $uri;
if((!isset($this->request->get['route'])) AND (trim($uri) <> '')){
if(array_key_exists($uri, $this->pages)){
$this->request->get['route'] = $this->pages[$uri];
return $this->forward($this->pages[$uri]);
}
}
}
}


Reply With Quote
Bookmarks