Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Plugins for Plugins for Craft CMS

mccombs
November 11, 2014

Plugins for Plugins for Craft CMS

A short talk I presented at the Craft Austin meetup. In this talk I walk though setting up a basic plugin in Craft and a little insight to how we are selling plugins on Craft Plus - https://craftpl.us/

mccombs

November 11, 2014
Tweet

More Decks by mccombs

Other Decks in Technology

Transcript

  1. Choose a name that’s easy to remember Plugin names should

    be 1 word or an abbreviation Choosing a Name Anatomy of Plugin FIG. 1
  2. NameSpacesMatter Anatomy of Plugin FIG. 2 Plugin folders and urls

    File names and classes Always lowercase Always CamelCase
  3. Primary Plugin Class Anatomy of Plugin FIG. 3 Public facing

    info Plugin controls Name, Version, Developer, Developer URL Settings, hasCpSection, init, onAfterInstall, onBeforeInstall, on->Event
  4. Craft vs. MVC Anatomy of Plugin FIG. 4 Traditional MVC

    Craft Plugin MVC (VVSCMR) View -> Controller -> Model View -> Variable -> Service -> Controller -> Model -> Record
  5. Creating a plugin variable Anatomy of Plugin FIG. 5 {{

    craft.lemmings.widget("hello") }} Template Variable <?php namespace Craft; class LemmingsVariable { public function widget($lemmingName) {
 return craft()->lemmings->widget($lemmingName);
 } } index.html lemmings/variables/LemmingsVariable.php <?php 
 namespace Craft;
 class LemmingsService extends BaseApplicationComponent { public function widget($lemmingName) {
 return craft()->lemmings->widget($lemmingName);
 } } Service lemmings/services/LemmingsService.php > >
  6. Creating a plugin action Anatomy of Plugin FIG. 6 <form

    action="
 {{ actionUrl(‘lemmings/test') }}
 " method=“POST"> I am a form </form> Template Controller <?php namespace Craft; class LemmingsController extends BaseController { public function actionTest() { echo ‘hello world’; $this->redirect('/thanks'); } index.html lemmings/controller/LemmingsController.php >
  7. Introducing Casper Anatomy of Plugin FIG. 7 A barebones plugin

    Public facing info + admin templates + js/css resources Find Casper at https://craftpl.us/plugins or https://github.com/CraftPlus/Casper FREE
  8. Introducing Lemmings Anatomy of Plugin FIG. 9 A fully featured

    plugin CRUD functionality + embedded variable & asset access + plugin MIT license Find Lemmings at https://craftpl.us/plugins/lemmings
  9. Catch and Release A beating heart FIG. 5 > Plus

    Plugin Stripe Charge Email Admins Email Buyer w/plugin > Plus Plugin + Record Purchase Generate Serial Dashboard, charts and stats Buy Form stripe.js Plugin price, id