Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Adding a PayPal donate button

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

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

Page: 1 2
Go to End
Author Topic: 4857 Views
  • Briohny
    Avatar
    Community Member
    199 Posts

    Re: Adding a PayPal donate button Link to this post

    What about if you have different paypal buttons? i.e. buttons with different payment amounts.

    I thought that perhaps the following code would work, but it didn't.

    function Content() {
       return str_replace('$PayPal1', $this->PayPal1(), $this->Content);
       return str_replace('$PayPal2', $this->PayPal2(), $this->Content);
       }

       function PayPal1() {
       return 'replace me with paypal form html here!';
       }
       
       function PayPal2() {
       return 'replace me with paypal form html here!';
    }

    Any thoughts?

  • Briohny
    Avatar
    Community Member
    199 Posts

    Re: Adding a PayPal donate button Link to this post

    bump bump

    Any ideas anyone? I just want to be able to have a few different paypal buttons throughout the site.

    Cheers,
    Briohny

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Adding a PayPal donate button Link to this post

    @Briohny
    A "return" statement always leaves the method. That means your custom Content() method will finish after the first return statement.

    You should write something like that:

    function Content() {
    $tmp = str_replace('$PayPal1', $this->PayPal1(), $this->Content);
    return str_replace('$PayPal2', $this->PayPal2(), $tmp);
    }

  • Briohny
    Avatar
    Community Member
    199 Posts

    Re: Adding a PayPal donate button Link to this post

    Thanks that worked for two different buttons... what if i have more buttons though?

    4857 Views
Page: 1 2
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.