问题
Can I have a specific category layout for selected categories? The detail page will be the same, I need to get a custom tpl file.
Thanks for suggestions
回答1:
Pretty easy to do: override the category controller to set the template.
class CategoryController extends CategoryControllerCore {
// array with the selected categories
private $customCategories = array(1, 3);
public function init() {
parent::init();
if (in_array($this->category->id, $this->customCategories)) {
$this->setTemplate(_PS_THEME_DIR_.'category-custom.tpl');
}
}
}
Here you wouldn't be able to change the selected categories from the back office, but it would be easy to do with a module.
来源:https://stackoverflow.com/questions/18875349/prestashop-custom-layout-for-specific-category