Jump to content

Different layout templates for different pages


Recommended Posts

Hi, I just started developing for Prestashop and I'm looking for the best way to implement different layout templates for different pages, for example I want my front page to have no columns, just the wrapper container but the category pages should have a two column layout.

 

Looking at the `header.tpl` template of the default theme, I see it always builds the three column layout and uses the variables `$hide_left_column` and `$hide_right_column` to apply a CSS class and hide them accordingly.

 

I'm searching for a way to define a different template file, i.e. `header_container_only`, `header_2columns` for different pages, what would be the best approach for this?

 

Also where are the `$hide_left_column` and $hide_right_column` variables defined for each page?

Link to comment
Share on other sites

Hi there,

 

You just need to edit module positions in the back office. To hide the "column" on the index, you just add exceptions in modules. For example, go to modules, then module positions, find "left column modules" click edit on "block categories left" and add exception not to show on index. In this way, when you hide all blocks from the column, the column will be hidden and you will get one column index.

 

Other methos is css, but the one i described is better.

Link to comment
Share on other sites

 

 

Hi, I just started developing for Prestashop and I'm looking for the best way to implement different layout templates for different pages, for example I want my front page to have no columns, just the wrapper container but the category pages should have a two column layout.

read this: one column homepage prestashop tutorial - you can remove these columns with hooks, then save it like header_onecolumn.tpl

 

then, in classes/controller/FrontController.php

you have to edit this line:

$this->smartyOutputContent(_PS_THEME_DIR_.'header.tpl');

add there if conditions to check what "kind" of page customer browsing. you can add as many if coditions as you want, and define as many template files as you want too

  • Like 1
Link to comment
Share on other sites

  • 7 months later...

read this: one column homepage prestashop tutorial - you can remove these columns with hooks, then save it like header_onecolumn.tpl

 

then, in classes/controller/FrontController.php

you have to edit this line:

$this->smartyOutputContent(_PS_THEME_DIR_.'header.tpl');

add there if conditions to check what "kind" of page customer browsing. you can add as many if coditions as you want, and define as many template files as you want too

 

 

Can you please give an example of a condition to check "kind" of page?

Link to comment
Share on other sites

Just found how to do this, here is an example:

 

In the themes folder open your layout.tpl and then use the following logic to decide which header file you want to use for a specified page.

{if !empty($display_header) && $page_name != 'index'}
    {include file="$tpl_dir./header.tpl" HOOK_HEADER=$HOOK_HEADER}
{else}
    {include file="$tpl_dir./home_header.tpl" HOOK_HEADER=$HOOK_HEADER}
{/if}

 

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...