You are here

README.txt in Web Widgets 7

Same filename and directory in other branches
  1. 6 README.txt
Web Widgets
===========

"Copy/paste widgets for your Drupal site. Plays nice with Views."

Description
===========

Use Web Widgets to build dynamic snippets of your website that users can copy 
and paste to their websites.

Installation and Usage
======================

Web widgets can be used by any other module to generate copy/paste widgets. 
However, the most common use case is to use it together with Views module.

Here is how to use Web Widgets with Views: 

* Install Views http://drupal.org/project/views.
* Install Web Widgets.
* Create a new view
  - Add and configure a Page display (it needs a path ie /frontpage)
  - Add and configure a Widget display
    - Set its path ie /frontpage/widget.
    - Attach embed code to Page display.
* Now visit the page ie /frontpage.
  - You should see a text field with code that can be embedded on other websites.

API Usage
=========

The API functions are:
web_widgets_render_embed_code($style, $path, $width, $height);
web_widgets_render_widget($style, $content, $title, $add_target = TRUE);

$style can be google_gadgets, iframe, inline or uwa

1) Get the code what you can paste into the external site, for example:

$variables = array('path' => 'mywidget', 'width' => 100, 'height' => 500);
$embed_code = web_widgets_render_embed_code('inline', $variables);

2) In hook_menu(), define the path that you exposed in the widget embedding code, for example:

$['mywidget'] = array(
  '#page callback' => 'widgetfunc',
  '#access arguments' => array('access content'),
);

3) Generates the content inside the widget, for example:

function widgetfunc() {
  $title = 'example widget';
  $content = 'widget body';
  return web_widgets_render_widget('inline', $content, $title);
}

File

README.txt
View source
  1. Web Widgets
  2. ===========
  3. "Copy/paste widgets for your Drupal site. Plays nice with Views."
  4. Description
  5. ===========
  6. Use Web Widgets to build dynamic snippets of your website that users can copy
  7. and paste to their websites.
  8. Installation and Usage
  9. ======================
  10. Web widgets can be used by any other module to generate copy/paste widgets.
  11. However, the most common use case is to use it together with Views module.
  12. Here is how to use Web Widgets with Views:
  13. * Install Views http://drupal.org/project/views.
  14. * Install Web Widgets.
  15. * Create a new view
  16. - Add and configure a Page display (it needs a path ie /frontpage)
  17. - Add and configure a Widget display
  18. - Set its path ie /frontpage/widget.
  19. - Attach embed code to Page display.
  20. * Now visit the page ie /frontpage.
  21. - You should see a text field with code that can be embedded on other websites.
  22. API Usage
  23. =========
  24. The API functions are:
  25. web_widgets_render_embed_code($style, $path, $width, $height);
  26. web_widgets_render_widget($style, $content, $title, $add_target = TRUE);
  27. $style can be google_gadgets, iframe, inline or uwa
  28. 1) Get the code what you can paste into the external site, for example:
  29. $variables = array('path' => 'mywidget', 'width' => 100, 'height' => 500);
  30. $embed_code = web_widgets_render_embed_code('inline', $variables);
  31. 2) In hook_menu(), define the path that you exposed in the widget embedding code, for example:
  32. $['mywidget'] = array(
  33. '#page callback' => 'widgetfunc',
  34. '#access arguments' => array('access content'),
  35. );
  36. 3) Generates the content inside the widget, for example:
  37. function widgetfunc() {
  38. $title = 'example widget';
  39. $content = 'widget body';
  40. return web_widgets_render_widget('inline', $content, $title);
  41. }