├── JumpStart ├── config.php ├── templates │ ├── settings.html │ ├── add.html │ └── index.html ├── resources │ ├── icon.svg │ └── icon-mask.svg └── JumpStartPlugin.php └── README.md /JumpStart/config.php: -------------------------------------------------------------------------------- 1 | 'firstValue', 7 | 'secondSample' => 'secondValue' 8 | ); -------------------------------------------------------------------------------- /JumpStart/templates/settings.html: -------------------------------------------------------------------------------- 1 | {% import '_includes/forms' as forms %} 2 | 3 | {{ 4 | forms.textField({ 5 | label: 'Sample Text Field', 6 | instructions: 'Place your sample text here; JumpStart will save it.', 7 | name: 'sampleSetting', 8 | value: settings.sampleSetting 9 | 10 | }) 11 | }} 12 | -------------------------------------------------------------------------------- /JumpStart/templates/add.html: -------------------------------------------------------------------------------- 1 | {% extends '_layouts/cp' %} 2 | 3 | {% set title = 'JumpStart'|t %} 4 | 5 | {% set tabs = { 6 | first: { 7 | label: 'Sample Tab'|t, 8 | url: url('jumpstart') 9 | }, 10 | second: { 11 | label: 'Another Sample Tab'|t, 12 | url: url('jumpstart/new') 13 | } 14 | } %} 15 | 16 | {% set selectedTab = 'second' %} 17 | 18 | {% set content %} 19 |
Welcome to JumpStart. Start building!
20 | {% endset %} -------------------------------------------------------------------------------- /JumpStart/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends '_layouts/cp' %} 2 | 3 | {% set title = 'JumpStart'|t %} 4 | 5 | {% set tabs = { 6 | first: { 7 | label: 'Sample Tab'|t, 8 | url: url('jumpstart') 9 | }, 10 | second: { 11 | label: 'Another Sample Tab'|t, 12 | url: url('jumpstart/new') 13 | } 14 | } %} 15 | 16 | {% set crumbs = [ 17 | { 18 | label: 'JumpStart'|t, 19 | url: url('jumpstart') 20 | }, 21 | ] %} 22 | 23 | {% set content %} 24 |Welcome to JumpStart. Start building!
25 | {% endset %} -------------------------------------------------------------------------------- /JumpStart/resources/icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /JumpStart/resources/icon-mask.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |  2 | 3 | # JumpStart 4 | 5 | JumpStart is a well-structured starter package for plugin development. It 6 | assumes you're working with Craft 2.5. (Earlier versions won't have access to 7 | some of the Craft's newer features for plugins, like changelogs.) 8 | 9 | # Usage 10 | 11 | `git clone` the repo into your `craft/plugins` directory, then start building! 12 | 13 | If you rename your plugin immediately, be sure to rename your folder directory 14 | and any files inside so Craft can see them and associate them with your plugin. 15 | 16 | # Config or Settings? 17 | 18 | There's a little confusion for plugin developers about which one to use. The 19 | truth is that there's a benefit to using both. If you're building an extensive 20 | plugin that needs to do different things in different environments, you should 21 | go with a config file. If your plugin's relatively small, using Craft's built- 22 | in plugin settings is fine. 23 | 24 | Remember that the user likely won't have the tech skills to reach a config file 25 | in your plugin, so make sure any settings you place in it aren't critical to 26 | your plugin's administration. 27 | 28 | Use a config file if: 29 | - The setting needs to be different in each environment 30 | - Needs to be set dynamically via PHP 31 | - Needs to be version-controlled 32 | 33 | Use Plugin Settings if: 34 | - You need this setting to be easily updated by administrators 35 | - You need the setting to be validated 36 | - You need your plugin to run code when a setting's value changes. 37 | 38 | Also, remember that config files are completely optional; you don't need them to 39 | make a completely valid plugin. 40 | 41 | ### Retrieving and Overwriting Values 42 | 43 | You can retrieve values from your plugin's config file like this: 44 | 45 | `$configSettingValue = craft()->config->get('firstSample', 'jumpstart');` 46 | 47 | Your config's values can be overriden by end-users by placing a file with your 48 | plugin's name in their craft/config/ directory, ie: 49 | `craft/config/jumpstart.php` 50 | 51 | 52 | # Icons 53 | 54 | If you'd like to use an icon for your plugin, update the `icon.svg` file in 55 | `jumpstart/resources`. If your plugin will have its own CP tab, you'll need to 56 | also update the `icon-mask.svg`. 57 | -------------------------------------------------------------------------------- /JumpStart/JumpStartPlugin.php: -------------------------------------------------------------------------------- 1 | path->getPluginsPath() . 'jumpstart/resources/icon.svg'; 102 | } 103 | 104 | /** 105 | * Generates the HTML for your settings. This should almost always return a 106 | * template that renders from a twig file. 107 | * 108 | * @return string 109 | */ 110 | public function getSettingsHtml() 111 | { 112 | return craft()->templates->render('jumpstart/settings', array( 113 | 'settings' => $this->getSettings() 114 | )); 115 | } 116 | 117 | /** 118 | * Declare the settings for your plugin here. Get these values by calling 119 | * $this->getSettings() anywhere in THIS file. If you're trying 120 | * to do this in any other file, you'll have to go through the craft 121 | * plugins service, like so: 122 | * 123 | * craft()->plugins->getPlugin('jumpstart')->getSettings(); 124 | * 125 | * @return array 126 | */ 127 | protected function defineSettings() 128 | { 129 | return array( 130 | 'sampleSetting' => array(AttributeType::Mixed, 'default' => '') 131 | ); 132 | } 133 | 134 | /** 135 | * If your plugin needs its own item in the Navigation, set this to true. Be 136 | * Sure and update the icon-mask.svg file; it's the icon that shows next to 137 | * your plugin name in the CP Navigation. Delete this if your plugin doesn't 138 | * need a CP section. 139 | * 140 | * @return boolean 141 | */ 142 | public function hasCpSection() 143 | { 144 | return true; 145 | } 146 | } --------------------------------------------------------------------------------