Knowledgebase

How to exclude module blocks from particular pages in PrestaShop

In PrestaShop you can remove a module block from a position/hook and thus not display it in that position (e.g. the left column) on the frontend. It's also possible, however, to show the block in that position but exclude it only from certain pages. You can do this by editing the options of the module for the specific hook/position.

PrestaShop 1.5 and Newer Versions

If you use PrestaShop 1.5 or newer versions (e.g. PrestaShop 1.6), go to Modules menu>Positions sub-menu in the admin panel, scroll down the page to the position/hook to which the module is attached and click on the Edit button for that module. On the page that opens there's an option Exceptions that lists a lot of filenames. Each filename corresponds to one or more pages (e.g. category). If you don't want the module to be shown by the hook on a particular page, mark the corresponding name in the list. For example, if you mark category, then the module will not be shown on category pages. You can mark more than one item in the list. To do this, press and hold the Ctrl button on your keyboard and select the items. Don't forget to click on the Save button.

PrestaShop 1.4

In PrestaShop 1.4 modules are excluded from pages in a similar ways as with newer PrestaShop versions, but in this case you have to manually list the files corresponding to the pages.

For example, let's say that you want to hide the Specials block from the contact form and the sitemap page. Log in to the back office of your PrestaShop, then go to Modules tab>Positions sub-tab. On the page that opens you'll see listed all the blocks and the positions in which they appear. For more information on positions check out the tutorial on how to change the positions of modules in PrestaShop.

In our example the Specials block appears in the right column, so we find it listed in the right column section and we click on the edit icon for the block (a small pencil). On the page that opens for any of the blocks you'll see a field labeled Exceptions. In that field you can list the pages on which you don't want the particular block to appear. In our example we don't want the block to appear on the sitemap and the contact form page, so we list contact-form.php and sitemap.php, and we click on the Save button.

When you list more than one file separate them with commas. The pages correspond to the PHP files responsible for displaying them. You can find those files in the root PrestaShop directory on your hosting account. For example, if your PrestaShop is installed directly in the public_html directory on your PrestaShop hosting account, meaning it's accessible at yourdomain.com, then you can find those files in public_html. You can also get an idea of what to list in the Exceptions field by checking the URL address of the particular page.

For instance, the file category.php is responsible for displaying all category pages, while product.php shows all the product pages. You can go as far as excluding a block only for particular categories and products. For example, you have a category whose URL address is yourdomain.com/category.php?id_category=2, then to exclude a block from the pages of that category you need to put category.php?id_category=2 in the Exceptions field for that block. Remember that this will exclude the block only from the product-list pages of the category and not from the product pages that show the details for each product in the category (for this purpose you need to use the product.php file).

Was this answer helpful?

 Print this Article

Also Read