Jump to content

Smarty code for limiting current clients with an active product now is broken?


paperweight

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated