17488 Posts in 4473 Topics by 1978 members
| Go to End | Next > | |
| Author | Topic: | 4433 Views |
-
Adding a PayPal donate button

14 August 2007 at 4:52pm
I am about to pull my hair out! I see that SilverStripe's site has a donation page with a PayPal button, but mine isn't working. In fact, any code I put into the HTML thingy in the editor (I can only assume that's the only way to input HTML the way I want it?) chews it up and spits it out, not rendering anything right. What am I doing wrong?
I input my donate button code into the page content, through the HTML popup.
I update.
I save/publish.The code is mangled on the site. It attempts to show the PayPal button, to no avail. A view-source reveals that the rest of the code has been more or less erased.
I'm not too fond of the WYSIWYG editor, but could over-look it.... But as a not-for-profit, my site needs it's donate button! I need to be able to paste in code on my site as *I* want it to be... Does SilverStripe not allow that??
Thanks for any help!
-
Re: Adding a PayPal donate button

14 August 2007 at 5:14pm
Your might have to create a Donate Page type and then hard code the paypal donate link into the template. Have a read of the second tutorial on how to create a page type a brief one for you might be like
- mysite/code/DonatePage.php
class DonatePage extends Page {
}
class DonatePage_Controller extends Page_Controller {
}- mysite/templates/layout/DonatePage.ss
// all the normal page.ss stuff
// all custom Donate HTML StuffThen do a db/build. Refresh the CMS and make sure the Donate Page is of Page type - DonatePage.
Like I said, the second tut will probably provide better information
-
Re: Adding a PayPal donate button

14 August 2007 at 5:22pm
I hadn't even thought of that... I will do that. Thanks so much, willr!
-
Re: Adding a PayPal donate button

14 August 2007 at 5:31pm Last edited: 14 August 2007 5:37pm
Alternatively, you can do this:
In Page_Controller class, add this:
function Content() {
return str_replace('$PayPalForm', $this->PayPalForm(), $this->Content);
}function PayPalForm() {
return 'replace me with paypal form html here!';
}
These two functions allow you to enter $Paypal anywhere in the content editors within the CMS. It gives more flexibility instead of being dumped directly into the templates, if for example, you wanted the paypal button to come between 2 paragraphs of content.It just string replaces $Paypal with the HTML of the PayPal html. It works for anything really, including adverts if you wanted to throw them straight into the content (separate from the templates). Ideally it's good for little 'snippets' of external html or javascript.
$PayPalForm can be called in the templates, as well as in the content editor (WYSIYWG editor in the SS CMS).
Hope this helps!
Sean
-
Re: Adding a PayPal donate button

14 August 2007 at 5:36pm
I think I like that even more - So I can include the button in multiple places within the site. Thanks, Sean!
-
Re: Adding a PayPal donate button

14 August 2007 at 5:40pm Last edited: 14 August 2007 5:43pm
It's a more ideal solution as it works in both the templates and the CMS Content field (the rendered results of $Content.
There's also less overhead of not having to create another class (which creates db tables, etc).
Sean
-
Re: Adding a PayPal donate button

14 August 2007 at 6:45pm
man we need a page on doc with that stuff, when the hell could we do that ?!? thats awesome never even thought that was even possible! maybe I just never thought about it.. So i'm guessing that we can overload everything else like that Titles etc then sean?
-
Re: Adding a PayPal donate button

14 August 2007 at 6:49pm Last edited: 14 August 2007 6:55pm
We can do that indeed. It is in the wiki, but it's sort of hidden.
http://doc.silverstripe.com/doku.php?id=customising-content-in-your-templates
Check it out. It's there. Thanks to Sam for documenting this one, and coming up with the idea!
The simple things are always the most effective. It's just a string replace for the Content field to add some HTML in wherever it's found!
It's generally good when you can do function Title() {} to achieve $Title in the templates where your class doesn't inherit SiteTree functions - for example, if you're creating a class that extends DataObject like an article category or something.
Sean
| 4433 Views | ||
| Go to Top | Next > |



