Skip to content

Instantly share code, notes, and snippets.

@bumbu
Last active December 21, 2015 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bumbu/6225669 to your computer and use it in GitHub Desktop.
Save bumbu/6225669 to your computer and use it in GitHub Desktop.
Front page links in admin of Prestashop 1.5.x
<?php
// override/classes/Dispatcher.php
class Dispatcher extends DispatcherCore
{
public static $controllerType = null;
public function getInstanceCustom($controllerType = 'public') {
self::$controllerType = $controllerType;
$dispatcher = new Dispatcher();
self::$controllerType = null;
return $dispatcher;
}
protected function __construct()
{
$this->use_routes = (bool)Configuration::get('PS_REWRITING_SETTINGS');
if (self::$controllerType) {
switch (self::$controllerType) {
case 'admin':
$this->front_controller = self::FC_ADMIN;
$this->controller_not_found = 'adminnotfound';
$this->default_controller = 'adminhome';
$this->use_routes = false;
break;
case 'module':
$this->front_controller = self::FC_MODULE;
$this->controller_not_found = 'pagenotfound';
$this->default_controller = 'default';
break;
case 'front':
default:
$this->front_controller = self::FC_FRONT;
$this->controller_not_found = 'pagenotfound';
$this->default_controller = 'index';
break;
}
} else {
// Select right front controller
if (defined('_PS_ADMIN_DIR_'))
{
$this->front_controller = self::FC_ADMIN;
$this->controller_not_found = 'adminnotfound';
$this->default_controller = 'adminhome';
$this->use_routes = false;
}
elseif (Tools::getValue('fc') == 'module')
{
$this->front_controller = self::FC_MODULE;
$this->controller_not_found = 'pagenotfound';
$this->default_controller = 'default';
}
else
{
$this->front_controller = self::FC_FRONT;
$this->controller_not_found = 'pagenotfound';
$this->default_controller = 'index';
}
}
$this->setRequestUri();
// Switch language if needed (only on front)
if (in_array($this->front_controller, array(self::FC_FRONT, self::FC_MODULE)))
Tools::switchLanguage();
if (Language::isMultiLanguageActivated())
$this->multilang_activated = true;
$this->loadRoutes();
}
}
<?php
// Usage
Context::getContext()->link->getPageLinkCustom('order', true, null, array('step'=>1, 'id_order'=>1), false, 'front');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment