Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » multiple paypal buttons

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: 4047 Views
  • Briohny
    Avatar
    Community Member
    199 Posts

    multiple paypal buttons Link to this post

    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.

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: multiple paypal buttons Link to this post

    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

  • Briohny
    Avatar
    Community Member
    199 Posts

    Re: multiple paypal buttons Link to this post

    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.

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: multiple paypal buttons Link to this post

    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: http://www.silverstripe.com/extending-hacking-silverstripe-forum/flat/128480

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

    Cheers
    Aaron

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: multiple paypal buttons Link to this post

    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.

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

    Cheers
    Aaron

  • Briohny
    Avatar
    Community Member
    199 Posts

    Re: multiple paypal buttons Link to this post

    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.

  • Briohny
    Avatar
    Community Member
    199 Posts

    Re: multiple paypal buttons Link to this post

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

  • Double-A-Ron
    Avatar
    Community Member
    604 Posts

    Re: multiple paypal buttons Link to this post

    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

    4047 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.