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.

Customising the CMS /

How I made the PayPal "Buy Now" button work


Reply


6 Posts   4051 Views

Avatar
Woody

Community Member, 3 Posts

15 January 2009 at 6:01pm

Edited: 16/01/2009 2:16am

So, after much gnashing of teeth i figured out how to get the PayPal "Buy Now" button to work correctly*. Here was my issue;

Using the PayPal "Merchant Services" "Buy Now Button", i was able to create the button, but when using the HTML functionality of SilverStripe, it just created the little table, but the button would not show up. There was nothing to click on, and hence no PayPal like functionality.

I'm not talking about the Ecommerce module, just pasting the provided HTML in the page and making it work. After moving thru the archives, and doing some reading, I got a feel for what the cause of the issue was. I wont bore you with that. Lets just get to what I did (in the end).

First, find your tinymce.template.js (mine was in the cms/javascript/ directory, I say that only because most of the posts don't tell you where to find the stinking files). Make a copy of it, just in case.

Open it with your favorite text editor and look for the following line;

valid_elements : "+a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align],-ol[class],-ul[class],-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],-td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-div[id|dir|class|align],-span[class|align],-pre[class|align],address[class|align],-h1[id|dir|class|align],-h2[id|dir|class|align],-h3[id|dir|class|align],-h4[id|dir|class|align],-h5[id|dir|class|align],-h6[id|dir|class|align],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir]",

and replace it with the following;

valid_elements : "+a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align],-ol[class],-ul[class],-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],-td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-div[id|dir|class|align],-span[class|align],-pre[class|align],address[class|align],-h1[id|dir|class|align],-h2[id|dir|class|align],-h3[id|dir|class|align],-h4[id|dir|class|align],-h5[id|dir|class|align],-h6[id|dir|class|align],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],form[accept|accept-charset|action|class|dir<ltr?rtl|enctype|id|lang|method<get?post|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onsubmit|style|title|target],input[accept|accesskey|align<bottom?left?middle?right?top|alt|checked<checked|class|dir<ltr?rtl|disabled<disabled|id|ismap<ismap|lang|maxlength|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|size|src|style|tabindex|title|type<button?checkbox?file?hidden?image?password?radio?reset?submit?text|usemap|value]",

Save the file and open your admin console. (Some of the archive posts talk about adding *everything* XHTML but I was not 100% on that. So, I just added what I thought was needed.) With those changes made open your target page and select the HTML button up on the second row. Paste your code from PayPal in the HTML window.

This will be the code that starts

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">

and ends with

</form>

Be sure to select Update and then Save & Publish.

Your PayPal "Buy Now" button should now be visible and accessable on that page. I hope this works for you as well as it did for me.

*I claim no expertise with SilverStripe, PayPal, or anything larger than 12 oz glass container. Edited for clarity and spellin'

Avatar
speedofmac

Community Member, 10 Posts

29 June 2010 at 6:28am

Edited: 29/06/2010 6:29am

I found this post extremely helpful. For this to work on SilverStripe 2.4, open "_config.php", which is located in the cms folder. Then, locate the line that begins with "extended_valid_elements" (it was line 40 for me) and add the following to that list:

form[action|method],select[name],input[type|name|value|src|alt|border],option[value]

I hope this helps someone!

Avatar
Woody

Community Member, 3 Posts

29 June 2010 at 6:50am

Awesome speedofmac, thanks for the update!

Avatar
speedofmac

Community Member, 10 Posts

30 June 2010 at 1:11am

Thank-you for the original tip! It saved me a pretty huge headache. I was able to get a series of PayPal buttons to work on a page by creating a holder page that grabbed information from its child pages, and those had fields for an item name, price, and so on. That worked well for what I needed, and it was really easy for a client to change, but this makes things even easier. Thanks again! At times I find the SilverStripe documentation a bit opaque, but I've had good luck with helpful information in the forums.

Avatar
Kereru

Community Member, 9 Posts

6 September 2012 at 9:33am

Are there any suggestions for how to make this work with Silvestripe 3.x?

Avatar
pinkp

Community Member, 168 Posts

22 June 2013 at 1:21am

Edited: 22/06/2013 1:29am

This worked for me for SS3.0.5

http://jeremyhixon.com/silverstripe-tinymce-and-complex-html/

replace line 14-26 of /framework/admin/_config.php

with

'valid_elements' => "* OPEN BRACKET * CLOSE BRACKET ",

(replacing caps with brackets)

Then paste your paypal button in the content editor in HTML mode.

Any one see any issues with this let me know?