Tony Reynolds Posted March 30, 2008 Share Posted March 30, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 I mistyped... when I tried $psword="" it literally displayed "$psword=""" over and over on my clients product details page for each loop it made. When i tried {$psword=""} my page would not display at all. Tony 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted March 30, 2008 WHMCS Developer Share Posted March 30, 2008 Hello: {php} $a = $this->get_template_vars('customfield'); //do whatever you need with the array $this->assign('newvariablename','variablevalue'); {/php} <i>{newvariablename}</i> Hows this????? 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 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} 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted March 30, 2008 WHMCS Developer Share Posted March 30, 2008 yeah - that should work. remember $a will now have all the customfield values in it. so $a.name in the PHP code used to be $customfield.name 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 Andrew, would it be possible for me to add this in and have you look at the finished product? Thanks again. Tony 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted March 30, 2008 WHMCS Developer Share Posted March 30, 2008 Sure :) 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 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} 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted March 30, 2008 WHMCS Developer Share Posted March 30, 2008 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} 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 Thanks so much Andrew. My knowledge of php is about nill. It took me 3 weeks and multiple hours of trial and errror to figure out what I had previously. I never would have figured this part out!! Your help has been absolutely great. Tony 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted March 30, 2008 WHMCS Developer Share Posted March 30, 2008 glad I could help 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 Andrew, I added the code and now my client products detail page will not display again. I have attached the modified clientareproductdetail.tpl. (turned to .txt file). I added ******************* to the code so you could quickly find the code. Thanks again. Tony clientareaproductdetails.txt 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted March 30, 2008 WHMCS Developer Share Posted March 30, 2008 Hi tony, add: $display_errors="on"; to you configuration.php file and see what errors come up, 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 Andrew, I got this: Fatal error: Smarty error: [in portal/clientareaproductdetails.tpl line 120]: syntax error: unrecognized tag 'uname' (Smarty_Compiler.class.php, line 583) in /home/pssathle/public_html/clients/libs/Smarty.class.php on line 1095 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted March 30, 2008 WHMCS Developer Share Posted March 30, 2008 me being blind there.. {uname} should be {$uname} {pword} should be {$pword} 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 The page is now displaying!!! However, I am seeing this displayed at the top of this custom field display area: variablevalue variablevalue Just the text "variablevalue" displayed twice 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted March 30, 2008 WHMCS Developer Share Posted March 30, 2008 you should replace the 'variablevalue' with whatever you need to display. Is it part of the custom field? or does it come from somewhere else 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 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? 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted March 30, 2008 WHMCS Developer Share Posted March 30, 2008 Ah, well, thats slightly different then: put this: $a = $this->get_template_vars('customfield'); $this->assign('uname',$a.value); 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted March 30, 2008 WHMCS Developer Share Posted March 30, 2008 try changing a.value to a['value'] 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 so it would be $a['value'] or just a['value']? 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 got it it is with the $ 0 Quote Link to comment Share on other sites More sharing options...
WHMCS Developer WHMCS Andrew Posted March 30, 2008 WHMCS Developer Share Posted March 30, 2008 sorry, $a['value'] 0 Quote Link to comment Share on other sites More sharing options...
Tony Reynolds Posted March 30, 2008 Author Share Posted March 30, 2008 Thanks again Andrew. I have to run to the store so I will get back to this later this evening. Thanks for the help. Tony 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.