DEV Community

Galaxy Littlepaws
Galaxy Littlepaws

Posted on

How To Hide Module in Prestashop 1.7 from Visitors/Guests

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)
Enter fullscreen mode Exit fullscreen mode

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)

kpodemski profile image
Krystian Podemski

It's totally fine to have a conditional statement like this inside your theme files :-)