Jump to content

Full page layout on categories with no filters


scottie

Recommended Posts

Prestashop 8.1

I copied the current classic theme and currently use the two column layout for category pages where filters show in the left column and product listing is in the right.  I want a full page layout when there are no filters for the category.  I overrode the CategoryController->initContent() to do this:
  

    public function initContent()
    {
        parent::initContent();
        
        if (
            Validate::isLoadedObject($this->category)
            && $this->category->active
            && $this->category->checkAccess($this->context->customer->id)
        ) {

            if ($this->category->id == 13 || $this->category->id == 14) {
                $template = 'catalog/listing/category-full';
            } else {
                $template = 'catalog/listing/category';    
            }

            var_dump($template);
            
            $this->doProductSearch(
                $template,
                [
                    'entity' => 'category',
                    'id' => $this->category->id,
                ]
            );
        }
 

The category-full.tpl extends another product-list-full-width.tpl that extends layout-full-width.tpl.  The problem that I'm running into is that even though the var_dump above says 'catalog/listing/category-full' is selected, the end result is as if the default category.tpl is used.  I confirmed this by simply changing the category.tpl to extend the same template the category-full.tpl does.  

I inserted a var_dump($template) in the ProductListingFrontController as well.  The result is a display:
string(24) "catalog/listing/category" string(29) "catalog/listing/category-full" string(29) "catalog/listing/category-full"

I'm having issue finding where the normal category.tpl is being "re-inserted" in place of what I've overridden in the above CategoryController.  doProductSearch is being called twice when landing on a category page.  I'm only able to find the one instance called from CategoryController.

Any help is appreciated.

Thanks,
Scott

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...