1
I finally got Smarty and templates working in an admin script. Here is some sample code, it's sure alot easier to write with smarty!
include '../../../mainfile.php';
include '../../../include/cp_header.php';
$op = "form";
if ( isset($HTTP_POST_VARS['op']) && $HTTP_POST_VARS['op'] == "submit" ) {
$op = "submit";
}
if ( $op == "form" ) {
xoops_cp_header();
require_once SMARTY_DIR.'Smarty.class.php';
$xoopsTpl = new Smarty;
$xoopsOption['template_main'] = 'ecngis_admin.html';
include XOOPS_ROOT_PATH."/header.php";
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";
//
// Just a sample checkbox
//
$tray_locale = new XoopsFormElementTray("");
$locale = new XoopsFormCheckBox("","Locale","0");
$locale->addOption("0","Locale");
$tray_locale->AddElement($locale);
$form = new XoopsThemeForm("", "layerform", "setlayers.php");
$form->addElement($tray_locale);
$form->assign($xoopsTpl);
$xoopsTpl->assign('lang_layers', _MM_LAYERS);
$xoopsTpl->display('db:'.$xoopsOption['template_main']);
xoops_cp_footer();
}
if ( $op == "submit" ) {
Normal coding stuff...
}
?>