For the past week or so I've been trying to solve this issue:
How to hide a module from someone not logged-in to a Prestashop 1.7 store. I'm newer to Prestashop so I've not gotten very deep into more advanced customization yet.
My specific use case was trying to hide the "IQITSEARCH" module search bar and the search results to anyone not logged-in. I tried removing access to the module in the admin panel for the Guest and Visitor groups, but no dice.
This is how I finally figured it out:
First you need to look into the relevant theme code .tpl files. The template files are written in Smarty. You can wrap what you want hidden like this:
{if $customer.is_logged}
// Things to only show if logged in (widget, etc)
{/if}
In my use case that was the theme-specific header tpl file.
Be sure to recompile the theme in Admin Panel โ Advanced Parameters โ Performance โ Smarty โ Template compilation. This way your changes actually go through and can be seen in your shop.
Please note that when the files are overwritten during an update to your template, you'll need to redo the customization.
If there are any Prestashop experts who have some tips to share, I'm eager to read what you have to say on the subject.
Top comments (1)
It's totally fine to have a conditional statement like this inside your theme files :-)