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

Adding a PayPal donate button


Go to End


12 Posts   6881 Views

Avatar
Briohny

Community Member, 199 Posts

7 October 2008 at 3:37am

Edited: 07/10/2008 3:37am

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?

Avatar
Briohny

Community Member, 199 Posts

11 October 2008 at 2:57am

bump bump :)

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

Cheers,
Briohny

Avatar
bummzack

Community Member, 904 Posts

11 October 2008 at 3:26am

@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);
}

Avatar
Briohny

Community Member, 199 Posts

12 October 2008 at 12:29am

Edited: 12/10/2008 12:39am

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

Go to Top