Integrating Your Category Tree on PrestaShop CMS Pages: A Guide to Hooks and Layouts
Integrating Your Category Tree on PrestaShop CMS Pages: A Guide to Hooks and Layouts
One of the strengths of PrestaShop lies in its modular architecture, allowing merchants to customize their storefronts with ease. However, sometimes a seemingly simple task, like displaying a core module on a specific content page, can present unexpected challenges. This community insight, drawn from a recent PrestaShop forum discussion (Thread #1110684), delves into a common query: how to display the 'Category tree links' module (ps_categorytree) on a PrestaShop CMS page.
The Challenge: Missing Category Tree on CMS Pages
The original post by YannT highlights a frequent pain point for PrestaShop users running version 8.2.7: they've created a custom CMS page and want to integrate the category tree module, but it simply isn't appearing. The user correctly questions whether "hooks" are available on content pages, indicating a good understanding of PrestaShop's module system.
Understanding PrestaShop Hooks and CMS Page Layouts
The replies from Shabab and Knowband Plugins provide comprehensive solutions, clarifying that PrestaShop CMS pages do indeed share the same front-office layout hooks as other page types (e.g., product, category pages). The key to solving this issue lies in understanding two main factors:
- Module Hooking and Exceptions: Modules are "hooked" to specific display positions (like
displayLeftColumn,displayRightColumn,displayNav,displayFooter). Importantly, modules can be configured with "exceptions," preventing them from appearing on certain page types. - Theme Layout Configuration: The layout chosen for your CMS pages (e.g., full-width, with left column, with right column) directly dictates which column-specific hooks are rendered by your theme's template files.
Step-by-Step Solutions to Display Your Category Tree
1. Check Module Position and Exceptions (Admin Panel)
The first step is to verify the module's configuration. Navigate to Design > Positions in your PrestaShop back office. Locate the 'Category tree links' module (ps_categorytree). Observe which hook it's attached to (typically displayLeftColumn or displayNav).
Crucially, click on the module's position to edit it and check the Exceptions tab. If "CMS pages" is listed or checked as an exception, this is likely preventing the module from showing. Simply uncheck or remove this exception to allow the module to render on CMS pages.
2. Adjust CMS Page Layout (Admin Panel - Easiest Solution)
Even if the module is hooked correctly and has no exceptions, it might not appear if your CMS page layout doesn't include the column where the module is hooked. This is a common scenario, especially with the default "Classic" theme, which often sets CMS pages to a "full-width" layout by default, thus omitting side columns.
The simplest fix, as suggested by Knowband Plugins, is to change the layout for your CMS pages:
- Go to Appearance > Theme and Logo.
- Click on Choose layouts.
- Find the entry for "CMS pages" and select a layout that includes the desired column (e.g., "Left column" or "Two columns, left and right").
After saving, the ps_categorytree module, if hooked to displayLeftColumn, should now appear on your CMS pages.
3. Manually Inject the Hook into Your Theme Template (Advanced)
If the above methods don't work, or if you require more granular control (e.g., your custom theme has radically altered the CMS page template), you might need to manually add the hook to your theme's template file. Shabab suggests this approach:
- Identify your theme's CMS page template file. For the Classic theme, this is often found in
templates/catalog/_partials/orpage-cms.tpl. If you're using a child theme, you'd modify the corresponding file in your child theme directory. - Open the relevant
.tplfile and insert the Smarty widget hook where you want the module to appear. For a left column, this would be:{widget hook='displayLeftColumn'}
This method ensures the column hook is explicitly rendered, allowing any modules attached to it (like ps_categorytree) to display.
Conclusion for PrestaShop Merchants and Developers
This forum thread provides excellent insights into a common PrestaShop customization challenge. It demonstrates that while PrestaShop offers robust module management, understanding the interplay between module positions, exceptions, and theme layouts is crucial for successful implementation. For e-commerce merchants and developers, these solutions offer actionable steps to enhance content pages with dynamic module content, improving user navigation and overall store functionality. Whether through simple back-office configuration or direct template modification, PrestaShop provides the flexibility to achieve your desired storefront design.