1

I am creating a selection of additional widgets to be used with the Widget addon. The widgets addon detects widgets that are placed into the following directory structure:

/third_party/your_addon/widgets/widget_name_1
/third_party/your_addon/widgets/widget_name_2
/third_party/your_addon/widgets/widget_name_3

I cannot figure out which type of add-on I need to create:

  • Plugin - I do not want to define a custom tag.
  • Module - I do not need to create a user interface in the control panel.
  • Extension - I do not need any hooks.
  • 3
    Hi Lea, this is really two separate questions, not one. This site's Q&A format needs single, discrete questions in order to work well. Please split your question about adding RTE formatting buttons into a new question so it can be answered separately. Thanks. – Tom Davies Dec 9 '12 at 7:22
  • 1
    @TomDavies I agree, I have moved the second question over here: expressionengine.stackexchange.com/questions/1364/… – Lea Hayes Dec 9 '12 at 16:17
3

You don't need to create a full EE addon (ie an extension, plugin or module) just to add an additional widget type to the Widgets addon. Widgets uses its own very simple format for defining new widgets, and rather than creating a new addon you just add a new directory with your widget's code in the widgets/widget directory ie in:

system/expressionengine/third_party/widgets/widget/your_shiny_widget

Each widget basically consists of a PHP class that extends the base Widget class and a couple of views, one for configuring the widget in the CP and one for displaying it when called in your template.

Have a look at the simplest included widget's code and if you know a bit of PHP it should be fairly straightforward to extend it to create your new widget.

| improve this answer | |
  • I think that this will be the simpler solution for now. There must be a way to add them to a custom add-on though because custom widgets are detected if I place them within the structure add-on folder. – Lea Hayes Dec 9 '12 at 16:18
  • I'm not sure that's a behaviour you should rely on. I suspect (but haven't checked) that's due to the way Structure loads files in its addon directory, such that your widget subclass file is getting executed automatically. Whatever the cause, it's not how Widgets is designed to load widget types, so it's probably best avoided. – Tom Davies Dec 9 '12 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.