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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Passing parameters into template.ss


Reply


5 Posts   1472 Views

Avatar
biapar

Forum Moderator, 435 Posts

3 July 2010 at 7:33pm

Edited: 07/07/2010 8:09pm

Is it possible to write into .ss file $Price_Product($ProductID)?

I've syntax error.

I create a workaround with a function that don't want parameters:

function Price_Product_2() {
$prod=DataObject::get_by_id('Product', $this->Product()->ID);
return $prod->PriceProduct;
}

Thank you

Avatar
biapar

Forum Moderator, 435 Posts

8 July 2010 at 1:07am

?

Avatar
ttyl

Community Member, 114 Posts

9 July 2010 at 3:00am

I don't think that is possible. I figured out some ways to do it before, but the implementation was weird - you couldn't pass in more than one argument or an argument with spaces. I was able to find work-around in my controller for what I was doing.

Avatar
swaiba

Forum Moderator, 1799 Posts

9 July 2010 at 3:20am

You can pass an argument into a $FunctionCall as long as it is hardcoded, e.g. $FunctionCall(5) but not using a $iVariable that has the value 5. Something about only having one pass of the template...

Avatar
biapar

Forum Moderator, 435 Posts

16 July 2010 at 11:20pm

I suppose...