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:
<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:
<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:
$id = 'id=';
$retval .= '<span class="wooo" price="true" text="In winkelwagen »">';
$retval .= '$id';
$retval .= '</span>';
return $retval;
It works partially, because it returns:
<span class="wooo" price="true" text="In winkelwagen »">$id</span>
But I cannot figure out the id part... Please help me out! Thanks.
Hello Jurgen,
it seemsto me that you're almost done.
Change some lines only:
<?php //colorize the code, ignore this line
$id = (isset($id)) ? $id : 'you forgot the ?id parameter';
$retval .= '<span class="wooo" price="true" text="In winkelwagen »">';
$retval .= $id; //remove the '' <- quotes from the variable, otherwise it will be put out asplaintext
$retval .= '</span>';
return $retval;
Regards,
Stefek
YES, that works beautifully! Very nice, thank you stefek, I really appreciate your quick help :-D
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
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.
Looks good, Jurgen.
Good luck with your project.
If you need help on droplets again, just ask. ;-)
Regards,
Stefek