Jump to content

How can I create conditional text for users using a specific server module?


Recommended Posts

I have a few different server modules, but I only want to show text in the Client Area to users who are using a specific server module. I think it is similar to this, but this is not correct:

 

{if $servermodule eq "servermod-name"}
show info to this user
{else}
show other info to user not using this server module...
{/if}

 

Any idea what I'm doing wrong?

Link to comment
Share on other sites

Thanks for your quick response. Right, so I see something like this but I am trying to figure out the correct syntax:

 

{$customserver1_products} Array (1)

58 => Array (8)

name => Server Maximum

username => testing999@domain.com

password => kjhu675dfg88yt78j7t68j5f78d65s

ipaddress => 98.222.34.45

status => Pending

nextduedate => 0000-00-00

suspended => 0

suspendreason => empty

 

So I have tried things like this:

{if $customserver1_products eq "Server Maximum"}

and also this:

{if $products eq "Server Maximum"}

 

but both seem not to work. I basically want to only display text to users who have purchased the "Server Maximum" product. I do not want to show that array, but I give it to you as an example of what I see on smarty debug~

Link to comment
Share on other sites

Thanks. I tried this:

{if $customserver1_products.name eq "Server Maximum"}

You are using the Server Minimum product. For more info, please visit the FAQ.

{else}

Would you like to upgrade to Server Maximum? Go here.

{/if}

 

But it still showed me "Would you like to upgrade to Server Maximum? Go here." for that same client who has "Server Maximum" in his array "noted above"... any thoughts on why?

Link to comment
Share on other sites

After using {debug} I see I am using the correct variables, but I think my syntax is incorrect. Any idea what I'm doing wrong according to the code?

 

When I run debug, I see this:

{$customserver1_products} Array (1)
58 => Array (
name => Server Maximum
username => testing999@domain.com
password => kjhu675dfg88yt78j7t68j5f78d65s
ipaddress => 98.222.34.45
status => Pending
nextduedate => 0000-00-00
suspended => 0
suspendreason => empty

 

And then I try to run this:

{if $customserver1_products.name eq "Server Maximum"}
You are using the Server Minimum product. For more info, please visit the FAQ.
{else}
Would you like to upgrade to Server Maximum? Go here.
{/if} 

 

But it still showed me "Would you like to upgrade to Server Maximum? Go here." for that same client who has "Server Maximum" in his array. Instead he should see "You are using the Server Minimum product. For more info, please visit the FAQ." but that is not happening :(

Link to comment
Share on other sites

The problem is this a two dimensional array, if it can have more than one product in it then you will want to loop over the array and check for the name in each array item. You could do this with some php code likes this (untested):

 

At the top of the template:

{php}
$customerserver_products = $this->_tpl_vars['customserver1_products'];
$server_maximum_found = false;
foreach($customerserver_products as $product) {
 if ($product['name'] == "Server Maximum") {
   $server_maximum_found = true;
 }
}
this->_tpl_vars['server_maximum_found'] = $server_maximum_found;
{/php}

 

 

Then where you want to display the message:

{if $server_maximum_found}
You are using the Server Minimum product. For more info, please visit the FAQ.
{else}
Would you like to upgrade to Server Maximum? Go here.
{/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