Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Send more than 1 param from template to a model function?

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

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

Page: 1
Go to End
Author Topic: 1289 Views
  • msantang
    Avatar
    Community Member
    41 Posts

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

    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

  • Sam
    Avatar
    Administrator
    679 Posts

    Re: Send more than 1 param from template to a model function? Link to this post

    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.

  • msantang
    Avatar
    Community Member
    41 Posts

    Re: Send more than 1 param from template to a model function? Link to this post

    Thanks i will give it a try.

  • msantang
    Avatar
    Community Member
    41 Posts

    Re: Send more than 1 param from template to a model function? Link to this post

    Yes, That resolve my problem tank you very much.

    1289 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.