Drupal Tutorials and Blog Posts

Use the Drupal Widgets Module For Reusable Content

widgetsThe Widgets module allows you to centrally manage text and code snippets across your Drupal site.

You can also combine the snippets into sets for even easier re-use.

Widgets provides some pre-defined snippets but also allows you create your own. In this tutorial we're going to do both.

We're going to show you how to:

  1. Use pre-defined widgets to show social bookmarks on your site.
  2. Create your own reusable content.

Using the Widget Module to Add Social Bookmarks

Install both of these modules:

Enable both of those Widgets modules:

tutuploadsmedia_1337699830252.png

Also, we're going to enable several of the Service Links modules. Which ones you choose will depend on the target audience for the site, but enabling the following three options will give me Facebook, Twitter, Google Plus and other popular options.

  • Favorite Services
  • General Services
  • Widget Services
tutuploadsmedia_1337700051651.png
  • Go to Structure > Blocks and publish the Widgets: widgets_service_link-default module.
tutuploadsmedia_1337699866780.png

The module will look like this on the front of your site:

tutuploadsmedia_1337700302017.png
  • If you want to modify that block, go to Structure > Blocks > Widgets.
  • You'll see that your service links widget is the only availabe at the moment.
tutuploadsmedia_1337700351946.png
  • Click Edit.
  • Click Override defaults at the bottom of the page.
  • You can now rearrange all of the social icons and also add more.
tutuploadsmedia_1337700501045.png

Creating Your Own Widgets

Widgets also allows you to create your own reusable widgets.

To make full use of the power of custom widget, install and enable these two modules:

Those two modules will allow our widgets to be much more fexible.

  • Go to Structure > Widgets > Definitions.
  • Click Add widget definition.
  • Definition name: Enter a name for your new widget.
  • Template: Enter the text or code you want to use. You can use tokens. You can find the tokens for your site by clicking Help > Token.
tutuploadsmedia_1337701184317.png
  • Repeat the process with another widget:
tutuploadsmedia_1337701120480.png

Now we're going to join the two widgets together into a widget set.

  • Click the Sets tab.
  • Click Add widget set.
  • Enter a Set name.
  • Click Create new set.
tutuploadsmedia_1337701314825.png
  • You can now add any of the widgets. We're going to add the new widgets that we have just created.
tutuploadsmedia_1337701354506.png
  • When you're finished, the widget set will look like the image below:
tutuploadsmedia_1337701390186.png
  • Save the widget set.
  • Go to Structure > Blocks and your widget will now show as a block. Publish this block.
tutuploadsmedia_1337701414661.png
  • You should now be able to see the widget set live on the site.
tutuploadsmedia_1337701490572.png
  • You'll also be able to re-use this widget almost anywhere on the site using tokens. Your new widget set will appear in the list of available tokens found in Help > Token.
tutuploadsmedia_1337701706493.png


Add comment


Security code
Refresh

blog-ad

Start Online Training

Members get access to all our video training. That's 1,142 training sessions in Joomla, Drupal, WordPress and Coding.

Manage All Your Joomla Sites

adminicredible

With Admincredible you can update and manage all your Joomla sites. If you have 5 or 500 sites, Admincredible will make your life easier! Visit Admincredible.com.

Latest Comments

The License for Our Tutorials

All of our tutorials are published under the Creative Commons Attribution-NonCommercial license. This means:

  • You can re-use these tutorials.
  • You can modify these tutorials.
  • You must link back to our original tutorial.
  • You can't use these tutorials commercially.

Click here to read the full license.

Open Source Training is not affiliated with or endorsed by the Joomla, WordPress or Drupal projects.
All product names and trademarks are the property of their respective owners.

Copyright 2013 Open Source Training, LLC. All rights reserved.