Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

Template Parameter Parsing Problem


Reply


3 Posts   1575 Views

Avatar
Terminator4

Community Member, 81 Posts

28 February 2009 at 12:10am

Hey guys,

If I try and put the following dynamic variable in my template I get an error:

$Top.ResortGroupForm($ID)

This is what the cached file is trying to do for this section and obviously the SSVIEWER is getting confused due to there being no differentiation with the ID and the ResortGroupForm objects

SSVIEWER;
$val .= $item->obj("Top")->XML_val("ResortGroupForm",array("
SSVIEWER;
$val .= $item->XML_val("ID",null,true) ;
$val .= <<<SSVIEWER
"),true) ;
$val .= <<<SSVIEWER

--------------------------------------------------------------------------------------------------

However, if I try a static value there is no problem:

$Top.ResortGroupForm(one)

The cached template looks like the following:

SSVIEWER;
$val .= $item->obj("Top")->XML_val("ResortGroupForm",array("one"),true) ;
$val .= <<<SSVIEWER

If anyone has a solution please provide it to me as it would be greatly appreciated.

Thanks

Avatar
Terminator4

Community Member, 81 Posts

28 February 2009 at 12:12am

I would presume that if the SSVIEWER for the argument was something like SSVIEWER_ARG then that would solve the issue

Avatar
Ben Gribaudo

Community Member, 181 Posts

4 March 2009 at 3:22am

Hi Terminator4,

At present, the template system doesn't support variables inside of template method calls (see http://doc.silverstripe.org/doku.php?id=templates#template_syntax). So, you can't do '$Property($OtherProperty)'.

As a workaround to this, you could add a method to your model that returns the equivalent of '$Property($OtherProperty)'. You could then call that new method from your template.

Hope this helps,
Ben