1
liomj
Assign Smarty variable to PHP with XOOPS 2.5.11-Stable
  • 1/3 3:29

  • liomj

  • Just popping in

  • Posts: 94

  • Since: 2012/4/10


lasttime before the xoops upgrade to smarty 3 this is working
<{assign var="cid" value=$downloads.cid}>    
<{
php}>
$catid=$this->get_template_vars('cid'); 
<{/
php}>


now after using
XOOPS 2.5.11-Stable with smarty 3

i receive this error
Error ErrorUsing $this when not in object context


how to update this code ?

2
Mamba
Re: Assign Smarty variable to PHP with XOOPS 2.5.11-Stable

In Smarty 3, the tags are no longer supported. Instead, you need to use Smarty's built-in functions and modifiers to accomplish tasks that previously required PHP code.

If you need both $cid and $catid, then you can use Smarty's $smarty.template_vars variable to access the template variable value instead of get_template_vars():

{assign var="cid" value=$downloads.cid}
{
assign var="catid" value=$smarty.template_vars.cid}


The $smarty.template_vars variable contains all assigned template variables and their values. So you can access the value of $cid through $smarty.template_vars.cid in place of the PHP code.

This allows you to eliminate tags and leverage Smarty's features and syntax to access template variables and perform other logic in the template.

Let us know if this worked
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

3
liomj
Re: Assign Smarty variable to PHP with XOOPS 2.5.11-Stable
  • 1/16 4:22

  • liomj

  • Just popping in

  • Posts: 94

  • Since: 2012/4/10


it does not work

actually this is for a customized block for tdmdownload modules

i solved it by editing the php file instead of the template file

4
Mamba
Re: Assign Smarty variable to PHP with XOOPS 2.5.11-Stable

Great to hear that you were able to fix it.

Please submit your improvements to GitHub

Thanks!
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

5
cadch
Re: Assign Smarty variable to PHP with XOOPS 2.5.11-Stable
  • 2/11 12:11

  • cadch

  • Just popping in

  • Posts: 51

  • Since: 2007/12/17


Quote:

liomj wrote:
lasttime before the xoops upgrade to smarty 3 this is working
<{assign var="cid" value=$downloads.cid}>    
<{
php}>
$catid=$this->get_template_vars('cid'); 
<{/
php}>


now after using
XOOPS 2.5.11-Stable with smarty 3

i receive this error
Error ErrorUsing $this when not in object context


how to update this code ?


<{assign var="cid" value=$downloads.cid}>    
<{
php}>
$catid=$_smarty_tpl->get_template_vars('cid'); 
<{/
php}>

try it~

6
Mamba
Re: Assign Smarty variable to PHP with XOOPS 2.5.11-Stable

As I've mentioned earlier, in Smarty 3, the <{php}> tags are no longer supported. Instead, you need to use Smarty's built-in functions and modifiers to accomplish tasks that previously required PHP code.
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

Login

Who's Online

388 user(s) are online (269 user(s) are browsing Support Forums)


Members: 0


Guests: 388


more...

Donat-O-Meter

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

Latest GitHub Commits