scysys Posted November 9, 2016 Share Posted November 9, 2016 I want to give users access to an closed section. How can i check in Smarty Templates if users has an active product for ProductID 49? Hope someone can help 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 9, 2016 Share Posted November 9, 2016 out of the box, you can't really - I suppose you could if say you added a link to the closed area in the clientareaproductdetails.tpl template for a PID 49 product because that page would have access to that variable... but that wouldn't help if the link became publicly known! otherwise, you'd need to write an action hook that would query the database, see if the client has an active PID49 and if so, set a Smarty variable... then in your template, you can either see if the variable exists and if so add a link to the closed area... or use it in the closed area and check if the variable exists... if so, they can enter... if not, they're shown an error message. the hook woudl be along the lines of... <?php use Illuminate\Database\Capsule\Manager as Capsule; function closed_area_access_hook($vars) { $client = Menu::context('client'); $allowaccess = Capsule::table('tblhosting') ->where('userid',$client->id) ->where('packageid','49') ->where('domainstatus','Active') ->count(); if ($allowaccess > 0) { return array("allowaccess" => $allowaccess); } } add_hook("ClientAreaPage", 1, "closed_area_access_hook"); ?> and then in your template, you can check if the variable exists... {if $allowaccess}qualifying product exists{else}no access allowed{/if} ... and replace the outputted text with your links or redirection etc. 0 Quote Link to comment Share on other sites More sharing options...
scysys Posted November 9, 2016 Author Share Posted November 9, 2016 That´s perfect, thank you Brian 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.