Jump to:

3435 Posts in 1026 Topics by 866 members

Template Questions

SilverStripe Forums » Template Questions » customising content in your templates

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

Page: 1
Go to End
Author Topic: 1402 Views
  • dataforlife
    Avatar
    Community Member
    10 Posts

    customising content in your templates Link to this post

    Hallo,

    i have a question to the http://doc.silverstripe.org/recipes:customising-content-in-your-templates

    This way i can use only one introduction, right? How can i use several introdutions?

    for examlpe 2:

    $Paypal for paypal.ss and $Pictures for pictures.ss

    function Content() {
       
          $replace = "";
          $replace .= str_replace('$Paypal', $this->PaypalButton(), $this->Content);
          $replace .= str_replace('$Pictures, $this->Pictures(), $this->Content);

        return $replace;
       }

    function PaypalButton() {
        return $this->renderWith("paypal");
       }

    function Pictures() {
        return $this->renderWith("pictures");
       }

    By this way the content of every page is shown twice. How can i do that right way?

    Thanks a lot!

  • ampedup
    Avatar
    Community Member
    133 Posts

    Re: customising content in your templates Link to this post

    The problem is you're concatenating content into the replace string twice.
    What you want to do is:

    function Content() {

    $replace = $this->Content;
    $replace = str_replace('$Paypal', $this->PaypalButton(), $replace);
    $replace = str_replace('$Pictures, $this->Pictures(), $replace);

    return $replace;
    }

    Give that a go.

  • dataforlife
    Avatar
    Community Member
    10 Posts

    Re: customising content in your templates Link to this post

    THANK YOU! Thats it!

    1402 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.