Jump to content

Carrying input field through Vertical Steps order form with PHP


Douglife

Recommended Posts

Hey everyone! First, let me say thanks to the WHMCS team for so many reasons, just awesome.

 

I'm working on a site, and I'm having trouble using Smarty and PHP in the TPL files (I believe).

 

Essentially, I have index.php which has a username field.

When the visitor enters their username, it is carried to the configureproduct.tpl and placed inside an input field.

 

I have it working using GET on php pages, but not the TPL files.

 

Here is my code:

 

<tr><td>{$customfield.name}:</td>
<td>{php}<input type="text" name="<?php echo $_GET["username"]; ?>" value="<?php echo $_GET["username"]; ?>">{$customfield.input}</input>
{/php}
{$customfield.description}</td>
</tr>

 

I've been using: http://www.smarty.net/docsv2/en/language.function.php.tpl for reference, but can't seem to figure it out.

 

Would love some expert insight into this, and hope you guys have the time! Thanks a TON!

Link to comment
Share on other sites

<tr>
 <td>{$customfield.name}:</td>
 <td>
   <input type="text" name="{$smarty.post.username}" value="{$smarty.post.username}" />
   {$customfield.input} {$customfield.description}
 </td>
</tr>

 

{php} {/php} is the equivalent of <?php ?> and you do not need to set it between {php}{/php}

 

Use php code only betweeen these smarty tags {php} {/php} and only if really needed. Should you use this, then make sure that nobody can download .tpl files. Protect it with a simply .htaccess:

 

## Deny template file access

<Files ~ "\.tpl$">

Order allow,deny

Deny from all

</Files>

 

Regards,

Marco

Edited by imaticon
typo in input tag
Link to comment
Share on other sites

Imaticon,

 

Thank you for that. I am definitely struggling when it comes to Smarty best practices.

 

You've provided a great solution to using PHP when need be, however I don't seem to be any closer to the task I mentioned above having a problem with, which is outputting <?php echo $_GET["username"]; ?> in the verticalsteps Configure Product TPL.

 

Hope you can assist! Thanks again!

Link to comment
Share on other sites

With pleasure!

 

Here is the custom field Smarty tags, and the bold item is where I'd like to output the carried GET input:

 

{if $customfields}
<p><strong>{$LANG.orderadditionalrequiredinfo}</strong></p>
<p>{$LANG.cartcustomfieldsdesc}</p>
<div class="orderbox">
<table>
{foreach key=num item=customfield from=$customfields}
<tr><td>{$customfield.name}:</td><td>{$customfield.input} {$customfield.description}</td></tr>
{/foreach}
</table>
</div>
{/if}

 

Thanks for your help!

Link to comment
Share on other sites

  • 4 weeks later...

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