1
mschmid
module dev: use smarty template in admin part
  • 2004/10/15 21:37

  • mschmid

  • Just popping in

  • Posts: 28

  • Since: 2002/9/19


The smarty works on the normal modules site of my programed module. But I wanna now add some admin functions. And for this I like to use also the smarty template. But it does not work. I found the following tread about the same question but not with an answer:

https://xoops.org/modules/newbb/viewtopic.php?topic_id=21907&forum=8

I have in the normal module that works:
----------------------------------
require('../../mainfile.php');
$xoopsOption['template_main'] = 'emailform.html';
require(XOOPS_ROOT_PATH.'/header.php');
$xoopsTpl->assign('itemSourceEmail', $refSourceEmail);
require(XOOPS_ROOT_PATH.'/footer.php');

In the Admin that does NOT work:
----------------------------
require('../../../mainfile.php');
include '../../../include/cp_header.php';
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";
$xoopsOption['template_main'] = 'emailform.html';
xoops_cp_header();
$xoopsTpl->assign('itemSourceEmail', $refSourceEmail);
xoops_cp_footer();

=> The error is: Call to a member function on a non-object in
line 270.
The line 270 is the $xoopsTpl->assign
Did I forgot an include?

Any input or remark where I can get more information will help
many thx
Markus

2
Draven
Re:module dev: use smarty template in admin part
  • 2004/10/15 21:59

  • Draven

  • Module Developer

  • Posts: 337

  • Since: 2003/5/28


The admin section does not use smarty. We are working to totally revamp the backend admin system from the ground up and it should include the use of smarty in future XOOPS versions starting hopefully at 2.1.

3
Dave_L
Re: module dev: use smarty template in admin part
  • 2004/10/15 22:32

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


It works now, but you have to add some code. Here's an example:

require_once 'admin_header.php';
require_once 
XOOPS_ROOT_PATH '/class/template.php';
...
xoops_cp_header();
...
if (!isset(
$xoopsTpl)) {
   
$xoopsTpl = new XoopsTpl();
}
$xoopsTpl->xoops_setCaching(0);
...
$xoopsTpl->assign('foo'$bar);
$xoopsTpl->display('db:admin/tpl1.html');
...
xoops_cp_footer();


admin_header.php contains:

<?php
require_once '../../../include/cp_header.php';
?>


The "if (!isset($xoopsTpl)) {" is an attempt at upward-compatibilty with future versions of XOOPS that have built-in support for admin templates.

Note that in the above example, the template admin/tpl1.html is in a subdirectory "admin" of the module's templates directory.

The template is also defined in the module's xoops_version.php:

$modversion['templates'][8]['file'] = 'admin/tpl1.html';
$modversion['templates'][8]['description'] = _MI_MODNAME_ADMIN_TPL1;


-----

P.S. I didn't figure all of this out by myself. The procedure was described in other posts.

4
Draven
Re:module dev: use smarty template in admin part
  • 2004/10/15 22:35

  • Draven

  • Module Developer

  • Posts: 337

  • Since: 2003/5/28


I was avoiding explaining the hack :)

5
mschmid
Re:module dev: use smarty template in admin part
  • 2004/10/15 22:41

  • mschmid

  • Just popping in

  • Posts: 28

  • Since: 2002/9/19


Many thx for the quick answer
==> will try the hack

Login

Who's Online

254 user(s) are online (172 user(s) are browsing Support Forums)


Members: 0


Guests: 254


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits