1
dragonfl
can this be done?
  • 2004/3/1 12:18

  • dragonfl

  • Just popping in

  • Posts: 16

  • Since: 2003/10/6


I am wondering if it is possable to do this..

I am working on a couple of modules for my site, and am wondering if you can make a call to the template file from within a function statement?

ie.

le="color: #000000"><?php function start() { $xoopsOption['template_main'] = "add_raid.html"; } if(!isset($HTTP_POST_VARS['op'])) { $op = isset($HTTP_GET_VARS['op']) ? $HTTP_GET_VARS['op'] : 'main'; } else { $op = $HTTP_POST_VARS['op']; } switch ($op) { case 'add_editB': add_editbank(); break; case 'addbank': addbank(); break; case 'delbank': deletebank(); default: case 'main': default: start(); break; }


now this is just a snipit of the code

Thanks Dragon

2
dragonfl
Re: can this be done?
  • 2004/3/3 15:16

  • dragonfl

  • Just popping in

  • Posts: 16

  • Since: 2003/10/6


bump.

-sorry-
does anyone know if this can be done, because all I get is a black page and no debug info when I try


Dragonfl

3
Mithrandir
Re: can this be done?

Should be possible, if you put a
le="color: #000000"><?php global $xoopsOption;

at the beginning of the function

4
Dave_L
Re: can this be done?
  • 2004/3/3 15:52

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


I would also change:

le="color: #000000"><?php if(!isset($HTTP_POST_VARS['op'])) { $op = isset($HTTP_GET_VARS['op']) ? $HTTP_GET_VARS['op'] : 'main'; } else { $op = $HTTP_POST_VARS['op']; }


to:



le="color: #000000"><?php if (isset($HTTP_POST_VARS['op'])) { $op = $HTTP_POST_VARS['op']; } elseif (isset($HTTP_GET_VARS['op'])) { $op = $HTTP_GET_VARS['op']; } else { $op = 'main'; }


Also, there are two instances of "default:" in the switch construct. The first one should be "break;".

5
dragonfl
Re: can this be done?
  • 2004/3/3 16:19

  • dragonfl

  • Just popping in

  • Posts: 16

  • Since: 2003/10/6


Thanks guys, whe I get home and am able to access my server I will try these to see if they work..

Dragonfl

6
Mithrandir
Re: can this be done?

If you want to support future developments rather than backwards compatibility, go with $_POST and $_GET instead of $HTTP_POST_VARS and $HTTP_GET_VARS - introduced in PHP 4.1.0 IIRC