Randem Systems Support Board

OpenCart => OpenCart MODS => Topic started by: Randem on December 27, 2015, 01:55:57 PM

Title: (Fix) Layouts not being chosen properly
Post by: Randem on December 27, 2015, 01:55:57 PM
I have changed the layout of the default store to use the default layout but it chooses some other other layout solely because it has common/home as the route. Why have a default selected if it is going to be overridden? I have changed the code to reflect proper choosing in the content_top / content_bottom / column_left / column_right / php files located in catalog\controller\common. The code should read as follows to facilitate this change. If you choose the "Default" layout in your store the default layout will be used, If you choose the "Home" layout (or something else) it will be used.

If you choose a layout, OpenCart should use that layout. This is the way I think it should work, Your ideas...


public function index() {
$this->load->model('design/layout');

if (isset($this->request->get['route'])) {
$route = (string)$this->request->get['route'];
} else {
$route = 'common/home';
}


$layout_id = null;

if ($route == 'product/category' && isset($this->request->get['path'])) {
$this->load->model('catalog/category');

$path = explode('_', (string)$this->request->get['path']);

$layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path));
}

if ($route == 'product/product' && isset($this->request->get['product_id'])) {
$this->load->model('catalog/product');

$layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']);
}

if ($route == 'information/information' && isset($this->request->get['information_id'])) {
$this->load->model('catalog/information');

$layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']);
}

if ($route == 'common/home') {
$layout_id = $this->config->get('config_layout_id');
}

if (!$layout_id) {
$layout_id = $this->model_design_layout->getLayout($route);
}

if (!$layout_id) {
$layout_id = $this->config->get('config_layout_id');
}


For the XML version of the fix look here (https://randemsystems.support/opencart/migrating-your-data-from-opencart-version-1-5-6-4-to-version-2-1-0-1/)