Jump to content

Display text if product is a server


Kelby

Recommended Posts

Hello,

I need to display a text in clientareaproducts.tpl if the product is a server, if the product is hosting or reseller I display another text:

  {if $productinfo.type eq "server"}       
 {elseif $productinfo.type eq "hostingaccount"}{else}{/if}

How to do it?

Link to comment
Share on other sites

{if $producttype eq "server"}{elseif $producttype eq "hostingaccount"}
                                  
<li class="divider"></li>
<li><a href=""><i class="glyphicon glyphicon-refresh"></i> {$LANG.clientareanavchangepw}</a></li>
                               
{else}
<li class="divider"></li>
<li><a href=""><i class="glyphicon glyphicon-refresh"></i> {$LANG.clientareanavchangepw}</a></li>
 {/if} 
                                  
</ul>
 </div>

This code isn't working for me

Link to comment
Share on other sites

27 minutes ago, Kelby said:

{if $producttype eq "server"}{elseif $producttype eq "hostingaccount"}
                                  
<li class="divider"></li>
<li><a href=""><i class="glyphicon glyphicon-refresh"></i> {$LANG.clientareanavchangepw}</a></li>
                               
{else}
<li class="divider"></li>
<li><a href=""><i class="glyphicon glyphicon-refresh"></i> {$LANG.clientareanavchangepw}</a></li>
 {/if} 
                                  
</ul>
 </div>

This code isn't working for me

Your Code Like to this.... 


{if $producttype eq "server"}
                                  
<li class="divider"></li>
<li><a href=""><i class="glyphicon glyphicon-refresh"></i> {$LANG.clientareanavchangepw}</a></li>
                               
{elseif $producttype eq "hostingaccount"}
<li class="divider"></li>
<li><a href=""><i class="glyphicon glyphicon-refresh"></i> {$LANG.clientareanavchangepw}</a></li>

 {/if} 
                                  
</ul>
 </div>
Link to comment
Share on other sites

16 minutes ago, Kelby said:

This code isn't working for me

it would work...

YsLx2jL.png

but perhaps you're editing the wrong template - depending on where the output is going to be, and what the module being used it, you might need to use the cPaenl template rather than the clientareaproductdetails.tpl template.

btw - the logic of that if statement is that if producttype equals server, then do nothing - but if you're going to do nothing for a condition, you don't really need to include that condition.

if you wanted the first line to be if product is server OR hostingaccount, then do something,  it would be...

{if $producttype eq "server" OR $producttype eq "hostingaccount"}
Link to comment
Share on other sites

8 minutes ago, Kelby said:

How to achieve that ?

depending on where you're outputting this, you might need to change multiple templates....

8 minutes ago, Kelby said:

If the product is a VPS server then not showing the ChangePassword option.

that could be for one of two reasons...

  1. either you're using your template code above that says to do nothing if it's a server - if so, WHMCS is doing what you ask and outputting nothing if the current service is a server.
  2. or you're editing the wrong template and you might need to be looking at clientareaproductdetails.tpl
Link to comment
Share on other sites

4 minutes ago, Kelby said:

In My Products & Services page, I added a menu, And I need to show the Password Modification option only for WHM reseller and cPanel account, not for Servers. 

aah then that's a different question about a different page - out of the box, the products/services page wouldn't know the product type of a service... the best you can probably do without resorting to additional database checks would be to use $service.module in your condition and employ that to determine whether the current service it's a hosting product, server etc.

Link to comment
Share on other sites

3 minutes ago, Kelby said:

How to use $service.module?

your best friend for something like this is to add {debug} to the template, refresh the page and you should get a popup window of most available smarty arrays/variables...

then by examining the $service array in there, you should be able to tell which variables are available to you - specifically in your case, module (I think it's in there), and you can check those values to see if you can identify server product(s).

if yes, then it's just another if statement...

{if $service.module eq "some value"}do something{/if}
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