Question

A colleague made a small module to retrieve twitter search results based on user configurable search terms and display them in a block.

He is doing the searching with javascript to keep that traffic on the client side, something like: $.getJSON('http://search.twitter.com' etc.. Then when the json results are returned inserting them into the block, wrapping the returned data in html and appending it to the block.

Is there a way that this could be made themeable from the javascript layer? Without it being passed back into drupal and losing the bandwidth etc advantage of having it sit client side?

Was it helpful?

Solution

As of Drupal 6, modules providing/fetching dynamic content by means of javascript are supposed to turn that into HTML by calling Drupal.theme('function_name', ...) from the Drupal js namespace. Modules can/should provide their own js theming functions (or overrides) by adding them to the Drupal.theme.prototype namespace.

The mechanism is supposed to work similar to the standard theming mechanism, but is a bit insufficiently documented so far. See this entry in the module conversion guide, as well as the example towards the end of this post.

OTHER TIPS

Use semantic HTML and just style the generated HTML with CSS.

You could theme it entirely with CSS.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top