Let’s expand our Request a Consulting Quote screen to ask prospective customers a few other questions, such as the type of consulting engagement, and payment option.
Change the request.php
script to the following:
<?php include_once(‘Smarty.class.php’); $smarty = new Smarty; if (empty($_GET[‘language’])) { $smarty->assign(‘language’, ‘english’); } else { if ($_GET[‘language’] == ‘en’) { $smarty->assign(‘language’, ‘english’); } elseif ($_GET[‘language’] == ‘it’) { $smarty->assign(‘language’, ‘italian’); } } // list of available consulting types $smarty->assign(‘types’, array( ‘custom’ => ‘Custom Functions’, ‘review’ => ‘Code Review’, ‘database’ => ‘Database Design’, )); // list of possible payment options $smarty->assign(‘payment’, array( ‘pre’ => ‘Pre-paid’, ‘aswego’ => ‘Pay as we go’, )); // list of available languages $languages = array( ‘en’ => ‘English’, ‘it’ => ‘Italian’, ‘de’ => ‘German’, ‘pt’ => ‘Portuguese’ ); $smarty->assign(‘languages’, $languages); $smarty->display(‘request.tpl’); ?>
Modify the request.tpl
template file so it contains the following:
{config_load file=”$language.conf” section=”Request”} {include file=”header.tpl”} {include file=”navigation.tpl” page_title=”Request a Consulting Quote”} <form method=”post” action=”request_quote.php”> <table border=”1”> <tr> <td bgcolor=”{cycle values=”#F0F0F0,#DDDDDD”}”>Name:</td> <td><input type=”text” name=”full_name” size=”40”></td> </tr> <tr> <td bgcolor=”{cycle values=”#F0F0F0,#DDDDDD”}”>Phone Number:</td> <td><input type=”text” name=”phone” size=”20”></td> </tr> <tr> <td bgcolor=”{cycle values=”#F0F0F0,#DDDDDD”}”> Appointment Date and Time: </td> <td> {html_select_date display_years=false} {html_select_time display_seconds=false minute_interval=15} </td> </tr> <tr> <td bgcolor=”{cycle values=”#F0F0F0,#DDDDDD”}”> Consulting Type: </td> <td>{html_checkboxes name=”type” options=$types separator=”<br />”}</td> </tr> <tr> <td bgcolor=”{cycle values=”#F0F0F0,#DDDDDD”}”> Payment Option: </td> <td>{html_radios name=”payment” options=$payment selected=”pre”}</td> </tr> <tr> <td colspan=”2” align=”center”> <input type=”submit” value=”Request”> </td> </tr> </table> </form> {include file=”footer.tpl”}
Reload the page in your web browser, and you should see something like the following:
There are several interesting features in this template:
{html_checkboxes}
function with the options
parameter, and you can customize how the checkboxes are separated. We are using line breaks here to make it easier for our users to visualize the options of consulting types.selected
parameter to the {html_radios}
function.13.58.39.23