What needs to be done now to ensure that more advanced features can be added in the future?
For example, something that would be nice would be the ability to create groups or lists of widgets (probably using taxonomy). Corresponding navigation tabs would then be provided within the widget to switch between widgets. That way, a number of widgets could be provided in one embedded widget.
Also, widgets that first display a login widget and then other widget(s) that require authentication to access is something to keep in mind.
I won't be able to implement many ideas during Summer of Code, but I'd like to keep the ideas flowing so that I can help make this project as extensible as possible.
Comments
Comment #1
nedjoI'm hopeful that the use case of combining various items can be addressed natively in Drupal through e.g. Panels rather than requiring us to combine different widgets.
Comment #2
jtsnow commentedMy reasoning behind including multiple widgets or multiple sources in one widget is that widgets are typically very small. To put more content in the small space, many third pary API's allow the creation of tabs. I am planning on implementing widgets as Google Gadgets as part of my summer of code project. The Google Gadgets API includes a tabs library: http://code.google.com/apis/gadgets/docs/ui.html#Tabs
You can then fill the widget tabs with content.
What if we put a "sources" field in the database schema? This field could hold an array of sources. Sources could be blocks, feeds, views, nodes, pages, etc. We could create a tab for each source. Then, when editing a block/page, we could have a form that lets the user add that block/page as a source in a widget that they have created.
For IFrame widgets, the sources can also be displayed as tabs/links across the top of the widget.
Comment #3
jtsnow commentedI have added the multi-widget functionality. It required changes in all the modules. I have set up a demo/test site. Rather than trying to scour through my code to see what I am talking about, try out the demo site:
http://www.deviable.com/widgets
Login with test/test. I have created a multi-widget that contains sources from blocks, views as blocks, and pages. I also created a simple widget theme.
Let me know if you like this direction or if we should scrap the multi-widgets idea. I think that adding tabs can be a powerful feature.
Comment #4
jtsnow commentedAlso, here is the patch for these changes. The code it needs quite a bit of work, but I wanted to get feedback on the UI and these new features.
Comment #5
nedjoThe demo is looking very good. I had a quick look at the patch, no time at the moment for thorough review. I'd say go ahead though. There's going to be a use case for this.
Comment #6
jtsnow commentedOk, I've integrated these changes. The official release is a mistake. (Still learning how to use CVS!) I've been looking for someone who can remove that for me.
I have a few ideas on how to improve upon the multi-source widget features:
Any thoughts?
Comment #7
jtsnow commentedI just found that the jQuery UI library also offers a tabs library. This would probably be more suitable than Yahoo's. Some demos:
http://ui.jquery.com/functional_demos/#ui.tabs
http://stilbuero.de/jquery/tabs_3/
Comment #8
nedjoHave a look at my Tabs module, http://drupal.org/project/tabs, which implements the jQuery UI tabs plugin. You could introduce it as a dependency.
Comment #9
alex ua commentedGiven jQuery's integration with Drupal I definitely think that you should go in that direction.
Comment #10
jtsnow commentedThanks nedjo, the tabs module works great, but I'm trying to determine the best way to implement the Tabs UI.
I have a working version where I simply add a 'tabpage' for each source in the widget...
That works fine. However, I have been using templates to theme the widgets. I could pass the contents of tabs_render($form) to my template and stick it in there, but that defeats much of the purpose of the template file away since much of the markup will be provided by tabs_render($form).
Adding the markup for the tabs in the template instead of having it rendered would be simple. I suppose I could then just call tabs_load() from my module, but that defeats much of the purpose of having the Tabs module as a dependency.
Is there another approach that I'm not seeing? I'd like to keep all the markup within the template file to keep things consistent.
Comment #11
nedjoTry this: specify a '#theme' callback for the tab pages and for the the tabset. Like this:
And ditto for the tabset. (Note two small changes I've made in your code: as of D7 there is now a space between a string and the . concatenator and I figure we might as well start using it; and Drupal uses underscores rather than camel case in variable and function names.) That should give you the theming flexibility you need.
Comment #12
jtsnow commentedThat makes sense, but is there a way to pass more arguments to the theme function in addition to $form? Or do I need to pass additional variables as elements of $form?
Comment #13
nedjoYes, you could add more form element properties if you need them.
What exactly are you needing to do? If it's allow a custom look for the tabset, can you achieve that just through CSS? If not, what are the changes needed to the rendered HTML that you need? Could you add what you need as a patch to tabs.module, improving the general themability of tabs and tabsets?
Comment #14
jtsnow commentedI am trying to make the template for iframe widgets as friendly as possible. Since I'm overriding the theme functions, all I really need from Tabs is the JavaScript. Currently, variables such as $page["breadcrumb"], $page["created"], and $page["taxonomy"] are available in the template. They need to be in a 'tabpage'. I could append them to $tab_content, but then their placement in the markup is set in stone.
The other option is making additional elements in the $form array like so:
This seems like extra overhead. Why not implement my theme as is, and simply include the JavaScript necessary to implement the Tabs UI?
Would that work?
Comment #15
nedjoI'm not totally following what you're doing. If you need to theme the content of a tab page, you can do so before adding it to a tab.
Does that not work? If not, can you improve the theming of tabs in tabs.module so that it does?
Before defaulting to just using the library directly, which of course is always an option, I'd like to understand the limitation that makes that necessary.
Comment #16
jtsnow commentedMy problems yesterday were because I wanted to theme the whole widget with just one template. Once I abandoned that I idea, this is what I came up with. Here is a patch of what I have so far.
Problems:
Comment #17
jtsnow commentedOk, I got it working. You can demo a widget using jQuery Tabs here: http://deviable.com/widgets/embed-widgets/3/tabs
It works perfectly except if the page is reloaded in FireFox, nothing is displayed, even though the HTML is output the same. In IE, everything works after reloading. Any idea why this is?
Here is the latest patch.
Comment #18
jtsnow commentedOld...