1
Venezia
$xoopsTpl - unexpected value for module name
  • 2003/10/27 2:02

  • Venezia

  • Just popping in

  • Posts: 36

  • Since: 2003/6/24


I am calling

$xoopsTpl->_tpl_vars['module']['name']

from a small php file I am including on the first line of footer.php in order to do some central collection of values that the modules have passed to the XOOPS template.

All the values passed by the individual modules are there, all correct. But the above call to get the module name, always returns the name of the module with the highest weight, ie the last module in main menu - not the currently loaded module as expected.

I know I can use $xoopsModule to get access to the name, but I wondered if this is an oversight in the core code, or is it the responsibility of the module coders to return the correct set of values in the ['module'] array?

Thanks
Venezia

2
onokazu
Re: $xoopsTpl - unexpected value for module name
  • 2003/10/27 7:45

  • onokazu

  • XOOPS Founder

  • Posts: 617

  • Since: 2001/12/13


$xoopsTpl->_tpl_vars is a private property of the XoopsTpl class, so it shouldn't be used from outside of the class. As you said, you would need to use $xoopsModule->getVar('name') to get the name of the current module.

3
Venezia
Re: $xoopsTpl - unexpected value for module name
  • 2003/10/27 8:20

  • Venezia

  • Just popping in

  • Posts: 36

  • Since: 2003/6/24


Thanks.

But if we shouldn't use _tpl_vars, what is the correct way to access values that have been stored in $xoopsTpl? (from a php file, not from an html template).

I'm more interested in the values passed by the current module to $xoopsTpl rather than the values stored by the xoopsModule object.

4
lubdub
Re: $xoopsTpl - unexpected value for module name
  • 2003/10/27 12:24

  • lubdub

  • Just popping in

  • Posts: 64

  • Since: 2002/2/28


Quote:

Venezia wrote:
But if we shouldn't use _tpl_vars, what is the correct way to access values that have been stored in $xoopsTpl? (from a php file, not from an html template).
I'm more interested in the values passed by the current module to $xoopsTpl rather than the values stored by the xoopsModule object.

Good question. I'm not (yet ) Smarty-savvy enough to answer that, but I'd say:
* if you reference them from a script invoked from your Smarty template, you probably can just reference them (or check the Smarty site)
* if you have filled data into the template in one script and want to retrieve in from another script, your design has a serious flaw. The xoopsTpl is a variable-container for inter-script data transfer.
(furthermore, the variables in the xoopsTpl don't come only from 'the current module', but from all module-blocks, ...)

5
onokazu
Re: $xoopsTpl - unexpected value for module name
  • 2003/10/27 13:24

  • onokazu

  • XOOPS Founder

  • Posts: 617

  • Since: 2001/12/13


If you really need to do that, you can also use the get_template_vars($name) function, where $name is the name of the template variable you have assigned.

6
Venezia
Re: $xoopsTpl - unexpected value for module name
  • 2003/10/28 1:27

  • Venezia

  • Just popping in

  • Posts: 36

  • Since: 2003/6/24


Thank you, that's the one I'm after.

Login

Who's Online

101 user(s) are online (82 user(s) are browsing Support Forums)


Members: 0


Guests: 101


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