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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Send more than 1 param from template to a model function?


Go to End


4 Posts   1802 Views

Avatar
msantang

Community Member, 41 Posts

11 May 2007 at 10:30am

How can i send more than 1 parameter from template to this function?

class ProductPage_Image extends Image {
function generateThumbnail(GD $gd, $width, $heigth) {
$gd->setQuality(90);
return $gd->paddedResize($width,$heigth,"F0F0F0");
}

public function Thumbnail($width,$heigth)
{
return $this->getFormattedImage('Thumbnail',$width, $heigth);
}
}

i try:

<ul id="ListaProductos">
<% control Children %>
<li>
<div class="Productonombre"><a href="$Link">$Title</a></div>
<div class="Productofoto">$Foto.Thumbnail(80,70)</div>
<div class="Productodescripcion"><p>$Content.FirstSentence</p></div>
</li>
<% end_control %>

But dint work, i get 1 parameter missing for Thumbnail function.

Thanks

Avatar
Sam

Administrator, 690 Posts

11 May 2007 at 3:52pm

The templating language has some weird little quirks in it.

Instead of:

$Foto.Thumbnail(80,70)

Try:
<% control Foto %>
$Thumbnail(80,70)
<% end_control %>

While we're on the subject, if anyone want to try and help rewrite the SSViewer parser, I'd be very appreciative and happy to point them in the right direction. :-)

Basically, it's currently built as a mess of regular expression search-and-replaces. It needs to be turned into a more sophisicated parser that uses a regular expression to find the <% control %> and $ tags, and something based on explode() and a for loop to work out how to parse the field/method reference itself.

Avatar
msantang

Community Member, 41 Posts

11 May 2007 at 11:23pm

Thanks i will give it a try.

Avatar
msantang

Community Member, 41 Posts

12 May 2007 at 9:56am

Yes, That resolve my problem tank you very much.