WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: Argos on October 29, 2010, 04:25:18 PM

Title: Trying to create simple droplet
Post by: Argos on October 29, 2010, 04:25:18 PM
I am trying to create a simple droplet, but being a non-coder this is even too difficult for me. Maybe someone can help me out. Must be very simple for coders  :roll:

I want this output:
Code: [Select]
<span class="wooo" price="true" text="In winkelwagen »">X</span>where X is the ID I want to set.

So for example I want to create:
Code: [Select]
<span class="wooo" price="true" text="In winkelwagen »">15</span>with a droplet like [[shop?id=15]]

After looking at other droplets I came up with this code, but it doesn't work:
Code: [Select]
$id = 'id=';
$retval .= '<span class="wooo" price="true" text="In winkelwagen »">';
$retval .= '$id';
$retval .= '</span>';
return $retval;

It works partially, because it returns:
Code: [Select]
<span class="wooo" price="true" text="In winkelwagen »">$id</span>
But I cannot figure out the id part... Please help me out! Thanks.
Title: Re: Trying to create simple droplet
Post by: Stefek on October 29, 2010, 04:32:08 PM
Hello Jurgen,
it seemsto me that you're almost done.

Change some lines only:
Code: [Select]
<?php //colorize the code, ignore this line

$id = (isset($id)) ? $id : &#39;you forgot the ?id parameter&#39;;
$retval .= &#39;<span class="wooo" price="true" text="In winkelwagen &raquo;">&#39;;
$retval .= $id//remove the &#39;&#39; <- quotes from the variable, otherwise it will be put out asplaintext
$retval .= &#39;</span>&#39;;
return $retval;

Regards,
Stefek
Title: Re: Trying to create simple droplet
Post by: Argos on October 29, 2010, 04:35:51 PM
YES, that works beautifully! Very nice, thank you stefek, I really appreciate your quick help  :-D
Title: Re: Trying to create simple droplet
Post by: Stefek on October 29, 2010, 04:40:02 PM
You're welcome.

The one thing was, you overwrote the variable delivered via [[droplet-macro]]
And the other thing: the single quotes around the variable.

Regards,
Stefek
Title: Re: Trying to create simple droplet
Post by: Argos on November 03, 2010, 01:19:03 AM
Thanks for the explanation!

By the way: I needed this droplet to use with a smooth little webshop script: http://codecanyon.net/item/woooshop-shopping-cart-for-every-website/108838

Mind you, it's a very basic shopping cart script, and the admin is not integrated into WB. But it's smooth jQuery and easy to use for clients that don't need a full featured webshop. The droplet can be used for clients to simply add Buy Now buttons to items on regular WB WYSIWYG pages. They only need the item ID from the shop script admin, and put that in the droplet.
Title: Re: Trying to create simple droplet
Post by: Stefek on November 03, 2010, 01:53:25 AM
Looks good, Jurgen.

Good luck with your project.

If you need help on droplets again, just ask. ;-)

Regards,
Stefek