Plugin behavior

bipster / 2012-12-21 13:15:39   

Hi!

I'm developing a PayPal button plugin using the following code:

  1. class paypal_button
  2. {
  3.   function show( $business='default@mail.com', $item_name='Default item', $amount=1 ) {
  4.     $html = '<form action="paypal.com/cgi-bin/…;
  5.              <input type="hidden" name="cmd" value="_xclick">
  6.              <input type="hidden" name="business" value="' . $business . '">
  7.              <input type="hidden" name="lc" value="ES">
  8.              <input type="hidden" name="charset" value="utf-8">
  9.              <input type="hidden" name="item_name" value="' . $item_name . '">
  10.              <input type="hidden" name="amount" value="' . $amount . '">
  11.              <input type="hidden" name="currency_code" value="EUR">
  12.              <input type="image" src="paypalobjects.com/es_ES/ES/i/btn/…;
  13.              </form>';    
  14.   return $html;
  15.   }
  16. }

But, for some reason if I call the plugin with no parameters:

<plugin:paypal_button:show />

the $business parameter is empty instead of using the default value.

Any ideas of what might be going on here?

Vaska A / 2012-12-21 15:54:37   

You're close...like this...

  1. <plugin:class_name:method param='hi','yes',more='like that' />

Personally, I feel that the email addresses should be either baked into the script or set via options. I wish I could write this tutorial right now but I'm a bit hung up with christmas already.

;)

bipster / 2012-12-21 20:17:31   

So, all parameters are required in the plugin call?

Vaska A / 2012-12-21 21:20:03   

Yes and no.

The first two, class name and method, yes. The others are optional.

If you must, you can simply use a function (not OOP) and call it thusly:

  1. <plugin:function_name parmeters='optional' />

This allows for some old plugins to work.

This thread has been closed, thank you.