predator
02-20-2009, 09:35 PM
Mod Title: Add Checkbox Forms
Last Updated: Feb.20, 2009
Supported by Mod Developer: No
Where to Download: none
Support Via This Thread or Download Site: This Thread
Compatible With: IE 7, FIREFOX
Below is how to add a checkbox form on submit.tpl and how to show the results on detail.tpl. It is a compilation of many discussions on the forum! There are many other variations but this should get you in the right direction! :)
Text in black is the code to change/insert and grey text is where to insert.
-------------------------------------------------------------------------------------------------
The new field in the database is here called "STYPES".
Database: ALTER TABLE ‘PLD_LINK’ ADD ‘STYPES’ VARCHAR(255) NULL
/templates/professional/Submit.tpl
<tr>
<td class="label">{l}Service(s){/l}:</td>
<td class="field">
<input type="checkbox" name="STYPES[0]" value="In-Office"{if !empty($STYPES[0])} checked="checked"{/if} >In Office
<input type="checkbox" name="STYPES[1]" value="In-Home"{if !empty($STYPES[1])} checked="checked"{/if} >In Home Services
</td>
</tr>
Submit.php
['OWNER_NAME'], 0, USER_NAME_MAX_LENGTH - 4).' ...' : trim ($data['OWNER_NAME'])) : '');
}
$data['DESCRIPTION'] = (!empty ($data['DESCRIPTION']) ? (strlen ($data['DESCRIPTION']) > DESCRIPTION_MAX_LENGTH ? substr ($data['DESCRIPTION'], 0, DESCRIPTION_MAX_LENGTH - 4).' ...' : trim ($data['DESCRIPTION'])) : '');
$data['META_DESCRIPTION'] = (!empty ($data['META_DESCRIPTION']) ? (strlen ($data['META_DESCRIPTION']) > META_DESCRIPTION_MAX_LENGTH ? substr ($data['META_DESCRIPTION'], 0, META_DESCRIPTION_MAX_LENGTH - 4).' ...' : trim ($data['META_DESCRIPTION'])) : '');
$data['META_KEYWORDS'] = (!empty ($data['META_KEYWORDS']) ? clean_meta_keywords($data['META_KEYWORDS']) : '');
$RegularLink_notif = true;
#File Uploader (after this if you have added the file uploader)
//checkbox start
if (is_array($data['STYPES']) && !empty($data['STYPES']))
{
$data['STYPES'] = implode (',', $data['STYPES']);
}
//checkbox end
if ($action == 'edit')
include/Tables.php
'STYPES' => 'C(255) NULL'
templates/professional/Detail.tpl
<tr>
<td class="label"> </td>
<td class="label">{l}Services{/l}:</td>
<td class="smallDesc" align="left">{$STYPES|escape|trim|replace:",":", "} </td>
</tr>
Detail.php
$data['STYPES'] = $rdata['STYPES'];
templates/core/defaultadmin/dir_links edit.tpl
<tr>
<td class="smallDesc"><label for="service">{l}Services{/l}:</label></td>
<td class="smallDesc">
<input type="checkbox" name="STYPES[0]" value="In-Office"{if in_array('In-Office', $STYPES)} checked="checked"{/if} >In Office <input type="checkbox" name="STYPES[1]" value="In-Home"{if in_array('In-Home', $STYPES)} checked="checked"{/if} >In Home Services
</td>
</tr>
admin/dir_links_edit.php
if (empty ($_POST['submit']))
{
$data['STYPES'] = explode (',', $data['STYPES']);
SmartyValidate :: connect($tpl);
And also add the following:
//Editor is on unallowed page, block access
http_redirect("unauthorized.php");
exit();
}
if (is_array($_POST['STYPES']) && !empty($_POST['STYPES']))
{
$data['STYPES'] = implode (',', $_POST['STYPES']);
}
if (SmartyValidate :: is_valid($data, 'dir_links_edit'))
{
Last Updated: Feb.20, 2009
Supported by Mod Developer: No
Where to Download: none
Support Via This Thread or Download Site: This Thread
Compatible With: IE 7, FIREFOX
Below is how to add a checkbox form on submit.tpl and how to show the results on detail.tpl. It is a compilation of many discussions on the forum! There are many other variations but this should get you in the right direction! :)
Text in black is the code to change/insert and grey text is where to insert.
-------------------------------------------------------------------------------------------------
The new field in the database is here called "STYPES".
Database: ALTER TABLE ‘PLD_LINK’ ADD ‘STYPES’ VARCHAR(255) NULL
/templates/professional/Submit.tpl
<tr>
<td class="label">{l}Service(s){/l}:</td>
<td class="field">
<input type="checkbox" name="STYPES[0]" value="In-Office"{if !empty($STYPES[0])} checked="checked"{/if} >In Office
<input type="checkbox" name="STYPES[1]" value="In-Home"{if !empty($STYPES[1])} checked="checked"{/if} >In Home Services
</td>
</tr>
Submit.php
['OWNER_NAME'], 0, USER_NAME_MAX_LENGTH - 4).' ...' : trim ($data['OWNER_NAME'])) : '');
}
$data['DESCRIPTION'] = (!empty ($data['DESCRIPTION']) ? (strlen ($data['DESCRIPTION']) > DESCRIPTION_MAX_LENGTH ? substr ($data['DESCRIPTION'], 0, DESCRIPTION_MAX_LENGTH - 4).' ...' : trim ($data['DESCRIPTION'])) : '');
$data['META_DESCRIPTION'] = (!empty ($data['META_DESCRIPTION']) ? (strlen ($data['META_DESCRIPTION']) > META_DESCRIPTION_MAX_LENGTH ? substr ($data['META_DESCRIPTION'], 0, META_DESCRIPTION_MAX_LENGTH - 4).' ...' : trim ($data['META_DESCRIPTION'])) : '');
$data['META_KEYWORDS'] = (!empty ($data['META_KEYWORDS']) ? clean_meta_keywords($data['META_KEYWORDS']) : '');
$RegularLink_notif = true;
#File Uploader (after this if you have added the file uploader)
//checkbox start
if (is_array($data['STYPES']) && !empty($data['STYPES']))
{
$data['STYPES'] = implode (',', $data['STYPES']);
}
//checkbox end
if ($action == 'edit')
include/Tables.php
'STYPES' => 'C(255) NULL'
templates/professional/Detail.tpl
<tr>
<td class="label"> </td>
<td class="label">{l}Services{/l}:</td>
<td class="smallDesc" align="left">{$STYPES|escape|trim|replace:",":", "} </td>
</tr>
Detail.php
$data['STYPES'] = $rdata['STYPES'];
templates/core/defaultadmin/dir_links edit.tpl
<tr>
<td class="smallDesc"><label for="service">{l}Services{/l}:</label></td>
<td class="smallDesc">
<input type="checkbox" name="STYPES[0]" value="In-Office"{if in_array('In-Office', $STYPES)} checked="checked"{/if} >In Office <input type="checkbox" name="STYPES[1]" value="In-Home"{if in_array('In-Home', $STYPES)} checked="checked"{/if} >In Home Services
</td>
</tr>
admin/dir_links_edit.php
if (empty ($_POST['submit']))
{
$data['STYPES'] = explode (',', $data['STYPES']);
SmartyValidate :: connect($tpl);
And also add the following:
//Editor is on unallowed page, block access
http_redirect("unauthorized.php");
exit();
}
if (is_array($_POST['STYPES']) && !empty($_POST['STYPES']))
{
$data['STYPES'] = implode (',', $_POST['STYPES']);
}
if (SmartyValidate :: is_valid($data, 'dir_links_edit'))
{