Jump to content

create a new variable???


Tony Reynolds

Recommended Posts

I would like to assign a value from a custom product field to a variable.

 

I have modified the clientareaproductdetails.tpl to conditioinally display some custom product fields.

 

If the customer has purchased a autoreponder membership and or shoppingcart membership thier UN and PW along with a link to the login area for the autoreponder will be posted.

 

This all works suprisingly well:lol:

 


{if $customfields}
<br />
<table cellspacing="1" cellpadding="0" class="frame"><tr><td>
<table width="100%" cellpadding="2">
{foreach key=num item=customfield from=$customfields}

<tr><td width="200" class="fieldarea">{$customfield.name}</td><td>{$customfield.value}</td></tr>

{if $customfield.name eq "Cart On" and $customfield.value eq "Yes" and $domain.value ne ""}<tr><td width="200" class="fieldarea">Cart Login</td>
<td><a target="_blank" <a href="http://{$domain}/admin">Here</a>{else}</td>{/if}</tr>

{if $customfield.name eq "Autoresponder On" and $customfield.value eq "Yes"}<tr><td width="200" class="fieldarea">Autoresponder Login</td><td> <a target="_blank" <a href="http://www.fitlistpro.com/ea/">Here</a>{else}</td></tr>{/if}

{/foreach}
</table>
</td></tr></table>

{/if}

 

 

Now I am trying to pass the UN and PW through the link so it will automatically sign them into the autoresponder. I think to do this I will need to put thier un and pw into a variable as it does its foreach-next through the list of custom fields. I will then place the variable into the hyperlink.

 

For some reason, i cannot seem to create a new variable.

Just to try decairing a simple variable I have tried placing $psword="" and {$psword=""} into the above code block and with both my client area products detail page goes blank.

 

So...it seems my problem is how to "declare" a new variable to be assigned the value of these custom fields.

 

Any feedback/thoughts would be greatly appreciated.

Tony

Link to comment
Share on other sites

Thanks Andrew. I think i will need some more guidance with this if you can.

 

Would this be what my code would look like that i would insert in the loop:

 

uname would be the new variable

and Autoresponder Username would be the name of the custom field

 

{if $customfield.name eq "Autoresponder Username" }

{php}
$a = $this->get_template_vars('customfield');
$this->assign('uname','variablevalue');
{/php}
<i>{uname}</i>
{/if}

Link to comment
Share on other sites

How is this?

 

{if $customfields}
<br />
<table cellspacing="1" cellpadding="0" class="frame"><tr><td>
<table width="100%" cellpadding="2">
{foreach key=num item=customfield from=$customfields}

<tr><td width="200" class="fieldarea">{$customfield.name}</td><td>{$customfield.value}</td></tr>


{if $customfield.name eq "Cart On" and $customfield.value eq "Yes" and $domain.value ne ""}<tr><td width="200" class="fieldarea">Cart Login</td>
<td><a target="_blank" <a href="http://{$domain}/admin">Here</a>{else}</td>{/if}</tr>

{if $customfield.name eq "Autoresponder User Name"}
{php}
$a = $this->get_template_vars('customfield');
$this->assign('uname','variablevalue');
{/php}
<i>{uname}</i>
{/if}

{if $customfield.name eq "Cart/Autoresponder Password"}
{php}
$a = $this->get_template_vars('customfield');
$this->assign('pword','variablevalue');
{/php}
<i>{pword}</i>
{/if}

{if $customfield.name eq "Autoresponder On" and $customfield.value eq "Yes"}<tr><td width="200" class="fieldarea">Autoresponder Login</td><td> <a target="_blank" <a href="http://www.fitlistpro.com/ea/index.php?action=login&username={$uname}&password={$pword}">Here</a>{else}</td></tr>{/if}


{if $customfield.name eq "Autoresponder On" and $customfield.value eq "Yes"}<tr><td width="200" class="fieldarea">Autoresponder Login</td><td> <a target="_blank" <a href="http://www.fitlistpro.com/ea/">Here</a>{else}</td></tr>{/if}

{/foreach}
</table>
</td></tr></table>

{/if}

Link to comment
Share on other sites

  • WHMCS Developer

Good, but you don't need to grab the variable if you're not gonna use it.. just put that in as an example:

 

{if $customfields}
<br />
<table cellspacing="1" cellpadding="0" class="frame"><tr><td>
<table width="100%" cellpadding="2">
{foreach key=num item=customfield from=$customfields}

<tr><td width="200" class="fieldarea">{$customfield.name}</td><td>{$customfield.value}</td></tr>


{if $customfield.name eq "Cart On" and $customfield.value eq "Yes" and $domain.value ne ""}<tr><td width="200" class="fieldarea">Cart Login</td>
<td><a target="_blank" <a href="http://{$domain}/admin">Here</a>{else}</td>{/if}</tr>

{if $customfield.name eq "Autoresponder User Name"}
{php}
$this->assign('uname','variablevalue');
{/php}
<i>{uname}</i>
{/if}

{if $customfield.name eq "Cart/Autoresponder Password"}
{php}
$this->assign('pword','variablevalue');
{/php}
<i>{pword}</i>
{/if}

{if $customfield.name eq "Autoresponder On" and $customfield.value eq "Yes"}<tr><td width="200" class="fieldarea">Autoresponder Login</td><td> <a target="_blank" <a href="http://www.fitlistpro.com/ea/index.php?action=login&username={$uname}&password={$pword}">Here</a>{else}</td></tr>{/if}


{if $customfield.name eq "Autoresponder On" and $customfield.value eq "Yes"}<tr><td width="200" class="fieldarea">Autoresponder Login</td><td> <a target="_blank" <a href="http://www.fitlistpro.com/ea/">Here</a>{else}</td></tr>{/if}

{/foreach}
</table>
</td></tr></table>

{/if}

Link to comment
Share on other sites

I have a custom field called "Autoresponder User Name" that holds the username. It is this username that I want to go into variable uname.

 

I just changed it to this and the text no longer appears.

$this->assign('uname',$customfield);

 

I thought this should read:

$this->assign('uname',$customfield.value);

 

but the .value would then display at the top of the custom fields area.

 

Also, should i remove the ' from around the uname text?

Link to comment
Share on other sites

I now have this:

 

{if $customfield.name eq "Autoresponder User Name"}
{php}
$a = $this->get_template_vars('customfield');
$this->assign('uname',$a.value);
{/php}
<i>{$uname}</i>
<tr><td width="200" class="fieldarea">{$customfield.name}</td><td>{$uname}</td></tr>
{/if}

 

I added the line below so i could see what value was held in the variable.:

<tr><td width="200" class="fieldarea">{$customfield.name}</td><td>{$uname}</td></tr>

 

 

It tells me $uname now equals= Arrayvalue

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