Pyrocms module or widget or plugin

2.2k views Asked by At

This is driving me mad! I want to include a simple contact form on a sites homepage. I can't work out if I need to build a module, widget or plugin. None of them seem to be quite right! Modules only seem to work as standalone pages eg the existing contact module. Widgets only seem to display data (got from db or some kind of feed eg twitter) and a plugin seems to be just like a library class. What I need is most like a module. I need a controller (to display the correct view and process the data from the form and views dependent on whether the form has been submitted or not. My problem is I can't work out how to include a module as a section of a page (just like you would a widget) instead of a page in it's own right.

1

There are 1 answers

2
Phil Sturgeon On BEST ANSWER

Any of those would work.

A module is a MVC triad that can interact with a URL, show views, have its own models, helpers, config, etc. A module is the full meat and two-veg.

A Widget is just a self-contained intelligent partial. That means it takes a few options from the Control Panel for each instance and spits out a chunk of HTML.

A Plugin is just a tag. This tag is used in the template, pages, news, whatever and spits out a chunk of HTML too. A Plugin can have various methods in the class, each method will be a different tag.

I have actually made contact forms as all of these types of addon, but the one I have settled on for PyroCMS v1.1 is a modular plugin. This means there are views, models, etc for the module but we can skip the controller and just make a plugin like so.

That plugin matches up to the tag:

{pyro:contact:form}

That is because it is in the contact module and the method is form. See? :)