The result of this form works great, but I got 1 main issue.
I need to set this value to the value it was when it got submitted. Essentially I need to keep the state of the dropdown list.
The code for this Smarty function is simple...
Code
<?php
function smarty_function_pagesetter_listSelector($args, &$smarty)
{
if (!isset($args['field']))
return "Missing 'field' argument in Smarty plugin 'pagesetter_listSelector'";
$field = $args['field'];
$name = isset($args['name']) ? $args['name'] : $field;
if (!pnModAPILoad('pagesetter', 'admin'))
return pagesetterErrorPage(__file__, __line__, 'Failed to load Pagesetter admin API');
$core = $smarty->get_template_vars('core');
$tid = $core['tid'];
$listID = pnModAPIFunc( 'pagesetter',
'admin',
'getListIDByFieldName',
array('tid' => $tid,
'field' => $field) );
if ($listID === false)
return pagesetterErrorAPIGet();
$listInfo = pnModAPIFunc( 'pagesetter',
'admin',
'getList',
array('lid' => $listID) );
if ($listInfo === false)
return pagesetterErrorAPIGet();
$items = $listInfo['items'];
$html = "<select name=\"$name\">\n<option value=\"top\"></option>\n";
foreach ($items as $item)
$html .= "<option value=\"$item[id]\">$item[fullTitle]</option>\n";
$html .= "</select>\n";
return $html;
}
?>
function smarty_function_pagesetter_listSelector($args, &$smarty)
{
if (!isset($args['field']))
return "Missing 'field' argument in Smarty plugin 'pagesetter_listSelector'";
$field = $args['field'];
$name = isset($args['name']) ? $args['name'] : $field;
if (!pnModAPILoad('pagesetter', 'admin'))
return pagesetterErrorPage(__file__, __line__, 'Failed to load Pagesetter admin API');
$core = $smarty->get_template_vars('core');
$tid = $core['tid'];
$listID = pnModAPIFunc( 'pagesetter',
'admin',
'getListIDByFieldName',
array('tid' => $tid,
'field' => $field) );
if ($listID === false)
return pagesetterErrorAPIGet();
$listInfo = pnModAPIFunc( 'pagesetter',
'admin',
'getList',
array('lid' => $listID) );
if ($listInfo === false)
return pagesetterErrorAPIGet();
$items = $listInfo['items'];
$html = "<select name=\"$name\">\n<option value=\"top\"></option>\n";
foreach ($items as $item)
$html .= "<option value=\"$item[id]\">$item[fullTitle]</option>\n";
$html .= "</select>\n";
return $html;
}
?>
I think I got to add "SELECTED" logic for a Smarty function, which is easy/
in essence, I think I need the following tag to work.
I just dont know how to retrieve the value of "value=" within the Smarty function. And I dont know if "$value" is the right syntax for retrieving form data and putting it in params of a Smarty function.
