paperweight Posted February 5, 2016 Share Posted February 5, 2016 I am upgrading my template from WHMCS v5.x to 6.x. I have a problem with the following Smarty not working: I first place this Smarty code in the head of the header.tpl: {php} // BEGIN TO CHECK IF USER HAS ACTIVE PRODUCT OR NOT - do NOT delete this because this affects all the navigation and internal pages // take the user's id $userID = $_SESSION["uid"]; // try to find that user among tblhosting to see if they in fact have a current paid product $sql = "SELECT id FROM tblhosting WHERE userid = ".$userID; $result = mysql_query($sql); $rows = mysql_num_rows($result); // if found if ($rows > 0) { $template->assign('isCurrentClient',"Y"); } // if not else { $template->assign('isCurrentClient',"N"); } // END TO CHECK IF USER HAS ACTIVE PRODUCT OR NOT {/php} Then in my clientarea .tpl templates I place code like this: {if $isCurrentClient eq "Y"}{if $clientsstats.productsnumactive>0} TEXT GOES HERE {/if}{/if} In v5.x the code above worked great. it allowed me to include information **only** for current clients who had at least 1 active service/product. But now the code above appears to not work. I checked the $this-> and $template-> changes but can't figure out what could still be wrong with the code above? Thanks for your thoughts and suggestions. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 5, 2016 Share Posted February 5, 2016 the Smarty {php} code works - but I can't see that you really need it. if all you want to do is display text to clients with active products, you could just use... {if $clientsstats.productsnumactive gt 0}TEXT GOES HERE{/if} if the client is logged in and has active products, then the above text will display; if they have no active products, it won't display... and if they're not logged in, $clientsstats.productsnumactive won't exist, will not pass the {if} test and so no text will be shown. 0 Quote Link to comment Share on other sites More sharing options...
paperweight Posted February 12, 2016 Author Share Posted February 12, 2016 Thanks for your help. That code still doesn't appear to work for me. I tried a very simple announcemets.tpl with the following code: {if $loggedin} {if $clientsstats.productsnumactive gt 0} SHOW THIS TEXT {else} {include file="$template/login.tpl"} {/if} If I remove the {if $clientsstats.productsnumactive gt 0} it works fine for the logged-in user. But nothing is shown (only the header and footer, but not the "SHOW THIS TEXT" or the login.tpl) if I retain that line. Any idea why? - - - Updated - - - Oh wow... wait.. I forgot a closing {/if}. Ok, now it works, but still some other problems... let me try going through again and seeing what is causing the issue. 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.