I see the main differentiation between snippets and plugins is the events that plugins can be hooked onto, as Briggsy says, things like OnWebPagePrerender.
Generally, snippets will return some form of output whereas a plugin may trigger an action and may not even affect the output of the content. But, the best way to fully understand the differences is to have a play with some of the existing snippets and plugins in the repository - there’s some great examples which you can learn from.
It’s difficult to pin down a basic structure for a snippet or plugin as they’re so damn versatile, lol!
Quote from: Briggsy at Mar 16, 2006, 02:08 PMAs far as I understand and I’m not a coder, is that a plugin will affect all pages. As Ryan mentioned it watches for system events. No doubt you could write a plugin to only affect some pages, but its basic function is to react on any page given the right system trigger, eg OnPageRender or OnWebLogout.
I’d agree, most plugins are designed to run across all pages but, in essence, you could write a module to select the pages that the plugin runs on - an example of this (although not directly linked to a module) is my Autolink plugin that doesn’t run on a page if it is derived from the blank template so as not to risk affecting any RSS feed output. Of course, the next logical step is integrating this selection process into the module.
As for an image gallery, one way of doing this is to create a module for all the administration (creating galleries, adding images etc.) and then using a snippet to control the output to the page.
Just my thoughts, Garry