Jump to content

Define variable php inside a template

Featured Replies

Posted

I am making some modifications in templates but the most easy thing I cannot do it. I can use php inside {{ }}, conditionals, functions whatever, but when I try to define a variable I received an error.

It is very easy to test, just open in the ACP one template and include this code:

{{ $var = 'test'; }}

And when you tried to save it the ACP will tell you "This theme file cannot be saved". I have tried the test in many templates and it is always the same, even using other options:

{ $var = 'test' }  {{$var = array();}}

But for the rest of php code as conditional and internal functions of php there is no problem. What am I doing wrong? Thank you

Just tested it with:
 

{{$test="test";}}
{$test}

It outputs test just fine, might be worth mentioning in which template you are trying to do this.

  • Author

It looks I have some error in my theme, because in a secondary theme I have I can define variables without problems. I am not sure what happen but it is just in this theme

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.