/entry_widgets

Add widgets to your entries, based on @philsturgeon's Widget Module

Primary LanguagePHP

Entry Widgets for ExpressionEngine 2

Example Widget Publish Page

Overview

Entry Widgets is a sideways port of Phil Sturgeon's recently open sourced Widget Module.

The fundamental difference between the Entry Widgets Module and the Widgets Module is as the name suggests - widgets are associated with regions within entries, rather than just regions.

  1. You have widgets: Eg, Latest Tweets, Latest News, Featured Products
  2. You have Areas & Entries
  3. You now have available instances of Widgets (with user defined parameters), within Areas, associated with Entries

The add-on is being developed to fill the need of having user defined parameters for 'features' around a page. For example, Entry Widgets enables you to break down an element like a simple call to action into it's various components:

Example Call to Action Widget

Advanced usage includes being able to utilize ExpressionEngine tags with widgets to have control over parameters. For example: Show x entries from x channel in x order.

Example Call to Action Widget

You get the idea.

Usage

Note, if you are using EE < 2.7.2 you'll need to apply a small fix to the ExpressionEngine core otherwise you'll get a fatal error on the publish page.

Installation

Add the files as per any regular EE add-on, and enable the Module & Fieldtype.

Configuration

Visit the module interface and add an Area. An area consists of a title and a short name - much like channels do. Create an initial area such as "Sidebar Features" and give it the short name "sidebar".

Then, create a custom field and associate the field with the area you created.

Config Overrides

You can move the system/expressionengine/third_party/entry_widgets/wigets directory to another location using the 'entry_widget_path' config override.

$config['entry_widget_path'] = "/Users/myusername/Sites/ee272.dev/widgets/";

The widgets folder should contain all the widgets for your project, for example

/system
/public
- index.php
- admin.php
/widgets
- /html_data
- /fancy_list
- /call_to_action
- /etc

Code Example

{exp:channel:entries limit="1"}

	<!-- call the field directly -->
	{my_widget_field}

	<!-- or if you want to loop through, use the alternate module syntax -->
	{exp:entry_widgets:render area="sidebar_features" entry_id="{entry_id}"}		
		{widget_count}
		{total_widget_count}
		{widget_body}
	{/exp:entry_widgets:render}

{/exp:channel:entries}

Each widget is located within the '/system/expressionengine/third_party/entry_widgets/widgets' directory and there are some examples for devs to review.

  • Call to action (simple set of fields for a call to action element)
  • Fancy List (example of repeating rows and various options/params)
  • HTML Data (simple html textarea)
  • Quote (simple set of fields for pullquotes)

Other information

If you're a designer who hasn't written a plugin before, you're not going really going to get a whole lot of benefit from this add-on. The strength of Entry Widgets lies in being able to create custom widgets for projects extremely rapidly. To do this, you're going to have to know a little php and be able to pick apart the examples to get what you need to know.

Enjoy.