How to start developing your own ExpressionEngine addons

27,815 views

Published on

Published in: Technology
2 Comments
4 Likes
Statistics
Notes
  • I have personally used this before, i'm satisfied with PREMIUM WOW GOLD DIGGER7.1
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Really helpful introduction and overview - especially the slide breaking down exactly what each of the different add-on types can do.

    Thanks!
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
27,815
On SlideShare
0
From Embeds
0
Number of Embeds
13,237
Actions
Shares
0
Downloads
68
Comments
2
Likes
4
Embeds 0
No embeds

No notes for slide
  • - Github: Create a new repo and suffix it with .ee_addon
    - developer_prefix.addon_name.ee_addon
  • - Github: Create a new repo and suffix it with .ee_addon
    - developer_prefix.addon_name.ee_addon
  • Documentation
    Marketing
    Sales
    Support
  • How to start developing your own ExpressionEngine addons

    1. 1. How to start developing your own addons http://newism.com.au / @newism
    2. 2. Leevi Graham • Developed 25+ addons over 2 years • First Addon: LG Better Meta - July 2007 • Technical Director at Newism • Devot:ee ExpressionEngine developer of the year • leevigraham
    3. 3. Introduction • Addon primer • Finding addons + development resources • Developing addons
    4. 4. Plugins
    5. 5. Strengths • Simple to build • Front end tag parsing • Custom field text formatting • Single PHP file
    6. 6. Strengths Weaknesses • Simple to build • No control panel adminstration • Front end tag parsing • Custom field text • No built in settings formatting • No language file • Single PHP file • No form submission processing
    7. 7. Image Sizer • Developed by: Lumis {exp:imgsizer:size • Resizes images - single image='foo.jpg' width='200' tag alt='My Title' • Caches output id='img_5334' class='entry_img' • http://www.lumis.com/page/ } imgsizer/
    8. 8. NSM Referrer Alert • Developer: Newism {exp:nsm_referrer_alert_pl} {if no_results}<p>No referrer found</p>{/if} <ul> • Outputs refer data in a <li>ref_scheme: {ref_scheme}</li> <li>ref_host: {ref_host}</li> tag pair <li>ref_port: {ref_port}</li> <li>ref_user: {ref_user}</li> <li>ref_pass: {ref_pass}</li> • <li>ref_path: {ref_path}</li> Check the number of <li>ref_query: {ref_query}</li> references <li>ref_fragment: {ref_fragment}</li> <li>ref_search_engine: {ref_search_engine}</li> <li>ref_search_terms: {ref_search_terms}</li> <li>ref_visit_count: {ref_visit_count}</li> • http://newism.github.com/ </ul> nsm.referrer_alert.ee_addon/ {/exp:nsm_referrer_alert_pl}
    9. 9. Modules
    10. 10. Strengths • Front end tag parsing • Control panel administration • Easy upgrade from plugin • Process form submissions
    11. 11. Strengths Weaknesses • Front end tag parsing • Multiple module and language files • Control panel administration • Multiple install locations • Easy upgrade from plugin • No built in settings • Process form submissions
    12. 12. Freeform • Developed by: Solspace • Custom forms • Record submissions in DB • Email notifications • http://www.solspace.com/software/ detail/freeform/
    13. 13. LG Quarantine • Developed by: Newism • Flag comments & entries as inappropriate • Quarantine comments / entries after n flags • Control Panel reporting • http://leevigraham.com/cms- customisation/expressionengine/lg- quarantine/
    14. 14. LG Quarantine • Developed by: Newism • Flag comments & entries as inappropriate • Quarantine comments / entries after n flags • Control Panel reporting • http://leevigraham.com/cms- customisation/expressionengine/lg- quarantine/
    15. 15. LG Quarantine • Developed by: Newism • Flag comments & entries as inappropriate • Quarantine comments / entries after n flags • Control Panel reporting • http://leevigraham.com/cms- customisation/expressionengine/lg- quarantine/
    16. 16. Extensions 'Take control'
    17. 17. Strengths • Extend existing tags • Extend control panel • Built in settings form - can be extended • All through hooks
    18. 18. Strengths Weaknesses • Extend existing tags • Must be activated • Extend control panel • No tag parsing • Built in settings form - • Hook registration + can be extended setting complexity • All through hooks
    19. 19. Hooks • Hook into the core EE processing • Over 170 hooks http://expressionengine.com/developers/extension_hooks/ • Hooks in use http://devot-ee.com/hooks/ • Extension class method called by EE when hook executed
    20. 20. Creating Hooks • Insert row into exp_extensions DB table • class: The current extension class • hook: The hook that calls the method • method: The class method to call • version: Extension version • settings: Serialised array of settings
    21. 21. EE Hook
    22. 22. EE Extension Hook method
    23. 23. Passes data EE Extension Hook method
    24. 24. Passes data EE Extension Hook method Returns modified data
    25. 25. Always check if someone else is using the same hook public function my_hook_method($html){ $this->get_last_call($html, ''); } /** * Get the last call from a previous hook * * @access private * @param mixed $param The variable we are going to fill with the last call * @param mixed $default The value to use if no last call is available */ private function get_last_call(&$param, $default = NULL){ global $EXT; if ($EXT->last_call !== FALSE) $param = $EXT->last_call; else if ($param !== NULL && $default !== NULL) $param = $default; }
    26. 26. FieldFrame • Developed by: Brandon Kelly • Easily add custom fields • Integrates with SAEF • http://brandon-kelly.com/ fieldframe
    27. 27. NSM Publish Plus • Developed by: Newism • Publishing workflow, drafts and revisions • Member publishing permissions • http://leevigraham.com/cms- customisation/expressionengine/ nsm-publish-plus/
    28. 28. NSM Publish Plus • Developed by: Newism • Publishing workflow, drafts and revisions • Member publishing permissions • http://leevigraham.com/cms- customisation/expressionengine/ nsm-publish-plus/
    29. 29. NSM Publish Plus • Developed by: Newism • Publishing workflow, drafts and revisions • Member publishing permissions • http://leevigraham.com/cms- customisation/expressionengine/ nsm-publish-plus/
    30. 30. Addons
    31. 31. Strengths • Powerful: Can change every aspect of an install • Combined strengths of all the components
    32. 32. Strengths Weaknesses • Powerful: Can change • Lots of files in many every aspect of an install different locations • Combined strengths of • Dependency on all the components components
    33. 33. Structure • Developed by: Travis Schmeisser • Organise EE content in a control panel module • Output navigation in the front end w/ custom tags • http://buildwithstructure.com/
    34. 34. Structure • Developed by: Travis Schmeisser • Organise EE content in a control panel module • Output navigation in the front end w/ custom tags • http://buildwithstructure.com/
    35. 35. Structure • Developed by: Travis Schmeisser • Organise EE content in a control panel module • Output navigation in the front end w/ custom tags • http://buildwithstructure.com/
    36. 36. LG Better Meta • Developed by: Leevi Graham • Add entry meta in a publish form custom tab • Output meta on the front end w/ custom tags • http://leevigraham.com/cms- customisation/expressionengine/ lg-better-meta/
    37. 37. LG Better Meta • Developed by: Leevi Graham • Add entry meta in a publish form custom tab • Output meta on the front end w/ custom tags • http://leevigraham.com/cms- customisation/expressionengine/ lg-better-meta/
    38. 38. Finding addons • Official Repository (144) http://expressionengine.com/downloads/addons/ • ExpressionEngine Forums (?) http://expressionengine.com/wiki/ • Devot:ee (480) http://devot-ee.com/add-ons/ • GitHub (114) http://github.com/search?q=ee_addon&type=Repositories • http://leevigraham.com http://leevigraham.com/cms-customisation/expressionengine/
    39. 39. Developing your own addons http://expressionengine.com/docs/development/ http://expressionengine.com/developers/ extension_hooks/
    40. 40. What will it do? Plugin Module Extension Addon Settings x x x Custom fields x x Custom tabs x x Custom tags x x x Modify existing tags x x Field text formatting x x Core manipulation x x Language files x x x Database tables x x x Process front end forms x x x
    41. 41. GitHub.com
    42. 42. nsm.custom_tab.ee_addon
    43. 43. /system /extensions /ext.nsm_custom_tab_ext.php /language /english /lang.custom_tab.php Addon /lang.custom_tab_ext.php /lib /nsm_custom_tab /views Folder /nsm_custom_tab /index.php /nsm_custom_tab_ext Structure /form_settings.php /publish_tab.php /modules /nsm_custom_tab /mcp.nsm_custom_tab.php /mod.nsm_custom_tab.php /themes /cp_themes Not so simple /nsm_custom_tab /admin.css /admin.js /site_themes /nsm_custom_tab /index.php /entry.php
    44. 44. /system /extensions /ext.nsm_custom_tab_ext.php /language /english /lang.custom_tab.php /lang.custom_tab_ext.php /lib /nsm_custom_tab /models /updates /views /nsm_custom_tab /index.php /nsm_custom_tab_ext /form_settinings.php /publish_tab.php /modules /nsm_custom_tab /mcp.nsm_custom_tab.php /mod.nsm_custom_tab.php
    45. 45. /themes /cp_themes /nsm_custom_tab /admin.css /admin.js /site_themes /nsm_custom_tab /index.php /entry.php
    46. 46. ! Code ahead !
    47. 47. Kicking off ext.nsm_custom_tab_ext.php Class Nsm_custom_tab_ext(){ var $name = 'NSM Custom Tab'; var $version = '1.0.0'; var $description = 'Adds a custom tab'; var $settings_exist = 'y'; var $docs_url = ''; public function __construct($settings=FALSE){ $this->settings = $setttings; } }
    48. 48. Add hooks var $hooks = array( 'lg_addon_update_register_source', 'lg_addon_update_register_addon', 'publish_form_new_tabs', 'publish_form_new_tabs_block', 'submit_new_entry_start', 'submit_new_entry_end', 'publish_form_start' ); public function enable_extension(){ global $DB; foreach($this->hooks as $hook){ // insert the hook into the exp_extensions table w/ // $this->settings } }
    49. 49. Implement settings public function settings_form($current_settings){ // add the page title // build crumb navigation // add PayPal donations button? // link to the module dashboard page? // link to help? ob_start(); include(PATH_EXT.'nsm_custom_tab_ext/views/form_settings.php'); $out .= ob_get_clean(); return $out; } public function save_settings(){ // process & serialize $_POST // save to exp_extension_settings table }
    50. 50. Add the tab // Add the tab public function publish_form_new_tabs($publish_tabs, $weblog_id, $entry_id) { $this->get_last_call($publish_tabs); $publish_tabs['tab_id'] = 'Tab label'; return $publish_tabs; }
    51. 51. Add the tab content // Add the tab content public function publish_form_new_tabs_block(){ $this->get_last_call($out, ''); $data = $this->get_tab_data(); ob_start(); include(PATH_EXT.'nsm_custom_tab_ext/views/tab.php'); $out .= ob_get_clean(); return $out; } // Get the tab content and merge in the preview / revision private function get_tab_data(){ $data = array('foo' => 'bar'); // merge the post data $post = $IN->GBL('Nsm_custom_tab_ext', 'POST'); return array_merge($data, $post); }
    52. 52. Process the submission // Validate the submission data public function submit_new_entry_start( $which, $errors, $entry_id){ global $IN; $data = $IN->GBL('Nsm_custom_tab_ext'); if($data['foo'] == '') $errors .= '<br />Another Error!'; if($errors){ $EE->new_entry_form('preview', $errors, $entry_id); $EXT->end_script = TRUE; } } // Save the submission data public function submit_new_entry_end($entry_id, $data){ // Take the post data and do what you need to like save to the database }
    53. 53. Quicksave // Runs before any data is processed public function publish_form_start($which, $error, $entry_id, $hidden){ global $IN; if(empty($entry_id)) $entry_id = $IN->GBL('entry_id'); // If the $which is save, jump to submit_new_entry_end() if($which == 'save' && $entry_id != FALSE){ $this->submit_new_entry_end($entry_id); } }
    54. 54. LG Addon Updater // register the xml versions source public function lg_addon_update_register_source($sources){ global $EXT; $this->get_last_call($sources); $sources[] = 'http://yoursite.com/versions.xml'; return $sources; } // register this addon public function lg_addon_update_register_addon($addons){ global $EXT; $this->get_last_call($addons); $addons['nsm_custom_tab_ext'] = $this->version; return $addons; }
    55. 55. Next steps
    56. 56. Free LG / NSM addons!
    57. 57. Thankyou. Questions? http://newism.com.au / @newism

    ×