7
Now I've implemented my first smarty template driven admin section.
I had to add a few lines of code.
Here's what I did.
In the admin page I added the following lines (Bold text is the original code, or test code!):
le="color: #000000"><?php [b]global $xoopsModule;[/b] [b]xoops_cp_header();[/b] require_once XOOPS_ROOT_PATH.'/class/template.php'; if ( !isset($xoopsTpl) ) { // Just in case, for new releases $xoopsTpl = new XoopsTpl(); $oldsystem = true; }else $oldsystem = false; $xoopsOption['template_main'] = 'ad_skel_testmenu.html'; // To be compatible with existing system. [b]// your code starts:[/b] [b]$xoopsTpl->assign( 'ModuleUrlPath', XOOPS_URL."/modules/".$xoopsModule->getVar('dirname'));[/b] [b]$xoopsTpl->assign( 'ModuleRootPath', XOOPS_ROOT_PATH."/modules/".$xoopsModule->getVar('dirname'));[/b] [b]$xoopsTpl->assign( 'goan', 'smee' );[/b] [b]// Your code ends.[/b] if ($oldsystem) { // Don't execute if newer versions has smarty implemented. if (isset($xoopsOption['template_main'])) { $xoopsTpl->xoops_setCaching(0); $xoopsTpl->display('db:'.$xoopsOption['template_main']); } } [b]xoops_cp_footer();[/b]
To go with this code, I made a template file called
ad_skel_testmenu.html' containing:
le="color: #000000"><?php <p> <center> <b>Admin smarty test!</b><br /> </center> Path is: <{$ModuleRootPath}><br /> Url is: <{$ModuleUrlPath}><br /> </p>
and finaly I added the following lines to the
xoops_version.php file:
le="color: #000000"><?php $modversion['templates'][1]['file'] = 'ad_skel_testmenu.html'; $modversion['templates'][1]['description'] = 'Test of smarty in admin..';
Thanks for your help everyone!
Idear:
It might be a good thing to place all admin templates in a directory called admin under templates, just like blocks.
We might aswell try to make a standard, so that smarty can be propperly implemented in the system, and modules will continue to function.