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.

Archive

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

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

multiple paypal buttons


Go to End
Reply

10 Posts   4157 Views

Avatar
Briohny

16 October 2008 at 9:49am Community Member, 199 Posts

I want to have 6 different paypal buttons throughout my website. Currently I have the following code in my page.php file.

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

function PayPal1() {
   return '<...paypal form code...>';
   }

function PayPal2() {
   return '<...paypal form code...>';
   }

It works fine for 2 buttons... but how do i change it so that it I can display 6. I've been mucking around with all the scripting but can't get it to work... I'm still getting used to the logic, definitions and coding of Silverstripe. :)

Thanks in advance.

Avatar
Double-A-Ron

16 October 2008 at 10:58am Community Member, 604 Posts

Hmmm, I don't like that Content() method, but that's an opinion.

Is there a reason why you simply don't use $PayPal1, $PayPal2 etc directly in your template? I don't know what logic is in <...paypal form code...> so I'm not sure if this is possible for you, but the Content() method just seems to be an uncessecary layer of functionality as far as displaying Paypal buttons is concern.

I would probably just embed the paypal form code directly into the template for that page if it were me.

Cheers
Aaron

Avatar
Briohny

16 October 2008 at 9:48pm Community Member, 199 Posts

Hey Double-A-Ron,

Thanks for your reply. I've tried embedding the paypal code directly into the HTML editor however it strips all the form functions and hence doesn't work. I want to be able to use $Paypal1, $Paypal2 etc directly into the HTML editor so that my client can manage the display and content of her site. I just need to be able to define each button as they have different parameters such as name, description and price.

An example of the code that needs to be placed in there for a Paypal button is:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
   <input type="hidden" name="cmd" value="_s-xclick">
   <input type="hidden" name="hosted_button_id" value="123456">
   <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynow_SM.gif" border="0" name="submit" alt="">
   <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
   </form>

The code in my first post works fine for 2 buttons but i need around 6 and i'm not sure of the correct coding.

I'd be happy to use another technique other than the Content() method but i just don't know any!

Any ideas?

Thanks.

Avatar
Double-A-Ron

16 October 2008 at 10:50pm Community Member, 604 Posts

Oh I see, so you are wanting to enter the HTML direct into the content field for the page in the CMS?

If so, it's actually TinyMCE that does the stripping there, not Silverstripe.

You can edit the TinyMCE setup to allow certain tags that aren't allowed by default. It only allows the most basic formatting and element attributes by default.

Have a look at this: [url]http://www.silverstripe.com/extending-hacking-silverstripe-forum/flat/128480[/url]

Let me know if I have misunderstood what you are doing.

Cheers
Aaron

Avatar
Double-A-Ron

16 October 2008 at 10:56pm Community Member, 604 Posts

And if you look at this on Moxiecode's Wiki, about halfway down is the string to set the editor to accept the full XHTML rule set.

[url]http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements[/url]

Cheers
Aaron

Avatar
Briohny

24 October 2008 at 6:59am (Last edited: 24 October 2008 9:08am), Community Member, 199 Posts

Sorry... only getting back to you now. Yep, that did the trick. Thanks.

edit: Actually no. I followed the instructions and changed the tinymce.template.js valid elements as explained in above 2 links and although it included most of the form paypal script, it still stripped the actual 'value' field which means it won't link through to the paypal payment page. I'm happy enough using the original 'content' script but just don't know how to manipulate the code. Or if you have any other ideas? Thanks again for your help.

Avatar
Briohny

24 October 2008 at 9:23am Community Member, 199 Posts

Ok... figured it out. All good! Thanks :)

Avatar
Double-A-Ron

24 October 2008 at 9:33am (Last edited: 24 October 2008 9:33am), Community Member, 604 Posts

Can you confirm that this only happens in IE but is ok in firefox?

Personally, I don't like this sort of hack. You open your app up to security issues and give your client far too much room to mess things up.

Do they really need to be able to change/move these buttons around the page?

Cheers
Aaron

Go to Top