X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Hide Menu Item Unless Member (https://forum.x-cart.com/showthread.php?t=77206)

Dawn Howard 09-24-2019 08:24 AM

Hide Menu Item Unless Member
 
Is there are a way to hide a header menu item unless the user is logged in with an approved membership?

Ed B. 09-24-2019 08:44 AM

Re: Hide Menu Item Unless Member
 
I guess it suffices to
  • create a @ManyToMany relations between the entities in models "menus" and "membership"
  • in your appropriate view class, define a function that tells if the user's membership is in related to the menu item
  • in appropriate twig file, you make sure that the menu item appears only if (s)he has the right membership using the function above
Of course, there will be usual routine routine writing of codes to edit the relations, add a an admin menu to open the editing page, etc. etc., unless you want to deal with the sql database directly.

cflsystems 09-24-2019 09:14 AM

Re: Hide Menu Item Unless Member
 
You can set menu item to show only for logged in customers but that's it. As long as customer is logged in the menu item will show regardless of membership.
If you need it for membership it has to be custom coded and extend the menu functionality to be able to set not only "logged in" but also memberships that apply.


An easier solution, however still involving some coding, will be to set the menu for logged in only and then if not-approved membership tries to go to the page redirect to static page with some explanation why it is not working for them. This approach is easier to do and will not involve any database changes and complicated admin/customer sides coding.


All times are GMT -8. The time now is 10:36 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.