Getting all variables

41 views
Skip to first unread message

93-interactive

unread,
Feb 14, 2011, 12:24:42 AM2/14/11
to H2o template PHP
Hi,

i am using h2o for a new cms and for the plugin system it is necessary
to get all variables in the template.

I have solved this so far by scanning through $h2o->nodelist->list and
get everything which is a instance of VariableNode.

Unfortunately this only works for templates not extending other
templates.

For now i solved this by getting all instances of Extends_Tag and then
create a new h2o object and scan for instances of VariableNode there.

This is not good, as for every extension i have to create a new h2o
object, is there a simple way to get all variables in a template,
including from parent templates?

Taylor Luk

unread,
Feb 15, 2011, 5:04:13 PM2/15/11
to h2o-temp...@googlegroups.com
Hello there,

H2o_Context object is where you want to look at, it holds all the variable in the template. You will be able access a instance of context object in any Tag class, look for the render methods "render($context)".

Thanks

Taylor Luk

> --
> You received this message because you are subscribed to the Google Groups "H2o template PHP" group.
> To post to this group, send email to h2o-temp...@googlegroups.com.
> To unsubscribe from this group, send email to h2o-template-p...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/h2o-template-php?hl=en.
>

93-interactive

unread,
Feb 16, 2011, 12:49:22 PM2/16/11
to H2o template PHP
Hi,

On Feb 15, 11:04 pm, Taylor Luk <subject...@gmail.com> wrote:
> Hello there,
>
> H2o_Context object is where you want to look at, it holds all the variable in the template. You will be able access a instance of context object in any Tag class, look for the render methods "render($context)".

thank you, unfortunately i think i did not understand.

If i var_dump $h2o->context, before rendering it is null, so i tried
the following:

$context = new H2o_Context($h2o->defaultContext(), $h2o->options);
var_dump($context);

Still i did not find where the variables are to find.
Reply all
Reply to author
Forward
0 new messages