Jump to content

How to hide product


Kian

Recommended Posts

Hi all

 

This is a part of my clientareaproducts.tpl (the page where customers can view the list of all their services)

 

{foreach key=num item=service from=$services}

<tr class="clientareatable{$service.class}">
<td>{$service.group} - {$service.product}{if $service.domain}<br /><a href="http://{$service.domain}" target="_blank">{$service.domain}</a>{/if}</td>
<td>{$service.amount}</td><td>{$service.billingcycle}</td><td>{$service.nextduedate}</td>
<td>
	<form method="post" action="{$smarty.server.PHP_SELF}?action=productdetails">
		<input type="hidden" name="id" value="{$service.id}" />
		<input type="submit" value="{$LANG.clientareaviewdetails}" class="button" style="margin:0" />
	</form>
</td>
</tr>

{foreachelse}

<tr class="clientareatableactive">
<td colspan="6">{$LANG.norecordsfound}</td>
</tr>

{/foreach}

 

We all know what it does. For each service it displays a row with product name, registration date, expiration date, "view details" button. If there's no service it displays "No record found". Ok now all i want to do is add a new display rule.

 

I want to hide from this list all services with a specific $pid basically something like...

 

{if $pid eq "50"}<tr style="visibility: hidden"></tr>{/if}

 

I tryed with several "foreach" format with no success. The question is: how can i exclude from the foreach cycle a service with a specific pid or at least how can i identify it to hide its row with css?

Link to comment
Share on other sites

I know that it could be made with Smarty {foreach}{continue} but i can't get it to work. i tryed to integrate this example with the code above with no success.

 

  {$data = [1,2,3,4,5]}
 {foreach $data as $value}
   {if $value == 3}
     {* skip this iteration *}
     {continue}
   {/if}
   {$value}
 {/foreach}
 {*
   prints: 1 2 4 5
 *}

 

Any idea?

Link to comment
Share on other sites

The pid isn't available from this page, so you would need to hide instead based on the product name or you need to make a database call to determine the pid and then hide based on the results. If you add {debug} to the top of this template, it will show you exactly what variables are available.

Link to comment
Share on other sites

I forgot to type $service.server.id instead of $pid that isn't available in clientareaproducts.tpl. Anyway i finally solved it thanks to Tews of Smarty. I was trying to use {continue} function that doesn't work with WHMCS's Smarty version. Solved with a simple if (no continue/break is involved).

 

Thank you anyway :)

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