MySite Droplets
For the new folks, Droplets are little snippets of HTML, JavaScript, and PHP code that function like Drupal Blocks, but Droplets are native to MySite. Views and Blocks can be converted to Droplets through an interface.
I know that some of you have created custom MySite Droplets. If you have, post them in a comment below.
Groups:
Login to post comments

Content Recommendation Engine
I wrote this one for patchak, but have not tested it.
It pulls recommendations for each user based on the Content Recommendation Engine.
The Droplet code would be something like that used by the user_recommendation_block() function. Try:
<?php
// get the user ID of the MySite page owner
$uid = intval(arg(1));
// create the content
$content = theme('item_list', user_recommendation_list_recommendations($uid));
// print the content
print $content;
?>
[Note: this code requires that the user_recommendation module of CRE is turned on.]
Create this as a new PHP Droplet and call it whatever you want.
--
http://ken.therickards.com/
http://savannahnow.com/user/2
http://blufftontoday.com/user/3
Any other site to find Droplets
¿Do you know where to find any other droplets or a guide to create some?
If it possible to the users to make (or modify) a block or a droplet?
thanks you
Guide
There isn't really a guide. There is the README.txt and the API: http://therickards.com/api
Here are the general rules.
1) You can convert existing Blocks and Views into Droplets. But once you do, they are not editable through the Droplet interface. This is by design.
2) You can create new HTML / JavaScript / PHP Droplets from scratch. This works almost identically to Block creation. The key is knowing which functions to use. Test with the Google Gadget link provided in the interface.
PHPTemplate theme snippets might be a good place to start.
If you really need to modify a a block or a view, the "easy" way is to find the function that generates it, copy that into a new Droplet and then make the changes you need.
Do you have a specific task you are trying to accomplish? If so, we might generate some documentation from that.
--
http://ken.therickards.com/
http://savannahnow.com/user/2
http://blufftontoday.com/user/3
Well, i am trying to make
Well, i am trying to make two diferents types of information for mysite.
The first one is to make a block with information extracted from an XML generate by other web, and i would like the user could select which of all the info want to show in his block/droplet.
Im not sure how to afford it.
The second one is similar to that, its about football.
I can get an XML with the latest N matches of one team (each user have a team). I would like to make one droplet that the user could select the number of matches to show. I kind of edit the droplet but withou use full code, only select the options...
If that possible with mysite?
Thanks for the info i have started to read abouth snippets. :D
Very possible
1) Getting the XML from the other site is fairly easy. Take a look at the StockAPI module, for example. The problem, right now, is that individual Droplets cannot declare their own settings options. Depending on the data from the other site, it my be better to create a Type plugin to handle the data.
2) Same basic answer. Very possible, although the user would not be allowed to select the count. A Type plugin would work better.
--
http://ken.therickards.com/
http://savannahnow.com/user/2
http://blufftontoday.com/user/3
Another question about
Another question about block/droplets.
Is it possible to make a droplet that coul show an image uploaded by the user?
Could the user upload up to 10 images and call them in a block? i was thinking about create them as profile content, so they could select them after, but im not sure if it is better to create a block/droplet to manage them.
Also... is it possible to duplicate the block with the profile content?
I hope you understand what i mean, my english is not so good. Thanks.
Not sute
Your English is pretty good. I am not sure what you mean, though.
To put user-uploaded images in a block, check hook_block() in the API. http://api.drupal.org. You could do this via a module and then display the block as a Droplet. There are a number of image-handling modules, so check them out first.
As for "is it possible to duplicate the block with the profile content?" Can you explain this more?
--
http://ken.therickards.com/
http://savannahnow.com/user/2
http://blufftontoday.com/user/3
I have investigated a lot
I have investigated a lot since my first message.
Now i know how to set a block with some data from the profile content, the picture, username, everything.
I use this code to connect :
$myuser = user_load(array('uid' =>$uid));profile_load_profile($myuser);
$phone = $myuser->profile_phone;
Also i set all the droplet code into this one:
$uid = intval(arg(1));if ($uid>0)
{ DROPLET CODE
}
To avoid errors when i am saving them as admin.
At this point "is it possible to duplicate the block with the profile content?" is not necesary :) Thanks anyway, but... i have new questions. :)
http://www.planetafreekick.com/mysite/darkpoll
you will see a table with the last 5 matches . (got them from XML, -another problem solved-, thanks again), but i dont know how to fix the table inside the droplet. Is there anyway to set the width of the droplet? or maybe is easy to make the table to adjust to it, i have this code for the table [it is only for testing purpose, not to be pretty ;)]
<table style="text-align: center; width: 100%;" border="1" cellpadding="2" cellspacing="2"><tbody>Thank you very much.
looks good
There is a profile.inc that ships with MySite, so you could just use that.
The table doesn't fit because the headers are too big; they force the table to be X pixels wide. There are CSS fixes for that, I think.
Not sure what the last question is "A select inside the droplet?" If you create a custom droplet and use PHP as the input format, you can insert whatever PHP code (including database queries) that you want.
Plugins and types are documented in the README.txt and in the API: http://therickards.com/api.
--
http://ken.therickards.com/
http://savannahnow.com/user/2
http://blufftontoday.com/user/3
>Not sure what the last
:)
Ok, my idea is to make a droplet with a form, the user can use a select to choose what kind of information want to show in the droplet. I am not sure if that is possible.
I dont how what is profile.inc, but im sure i can find something in drupal.org. ;)
Thank you and sorry because there is a lot of stupid questions, but i am very new with php and also with drupal.
See you.
It's fine
Nothing wrong with being new.
Adding a form in a Droplet won't quite work right now. You would need to make a specific Type plugin to handle that.
Profile.inc is provided by MySite. You are using it in the 'My Profile' section of your sample page. In fact, if you look at the code for profile.inc, you can see the way that MySite handles user-specific settings.
See http://therickards.com/api/file/plugins/types/profile.inc/MySite and http://therickards.com/api/function/mysite_type_hook_content_form/MySite
BTW: If you finish a translation, I'll be happy to load it into the download.
--
http://ken.therickards.com/
http://savannahnow.com/user/2
http://blufftontoday.com/user/3
Improving MySite Drag & Drop
I've played around with many implementations of Drag & Drop across different platforms. MySite's Drag & Drop functionality can sometimes be a bit jumpy. Perhaps others have experienced the same.
The best implementation (fast, light and compatible) I've come across is here:
Example: http://host.sonspring.com/portlets/
Code: http://sonspring.com/journal/jquery-portlets
Perhaps MySite could look to implement this to improve the Drag & Drop functionality.
Thoughts?
Pitch in
The current plan is to implement the jQuery UI to replace the existing jQuery Interface code. Interface is the library used in the example you cite, so I don't see how that code could be better than the current code. Perhaps the CSS styling is cleaner and therefore looks better to you?
However, it is possible that newer versions of Interface and jQuery perform better than the one currently implemented in Drupal. The jQuery Interface module does load extra code libraries that we do not use. But the jQuery Interface and jQuery Update modules are the most efficient means of letting people get the code they need.
We are actively looking for help with both JS and CSS implementations, so patches are appreciated.
--
http://ken.therickards.com/
http://savannahnow.com/user/2
http://blufftontoday.com/user/3
The simple way to do it ?
Isn't there a simple way to make configurable droplets ? For example, if I just want to make a droplet this way: there is an a field that the user fills in the configuration page of the droplet, and the droplet just displays the content of this field (The real application is more complicated). Do you I really have to create a new content type ? Besides, doing this way, the way to add a block is not very intuitive: the user must create the content and then the block corresponding (i am building an igoogle-like).
-- sorry, wrong thread,
-- sorry, wrong thread, please delete. --