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
5. Strengths
• Simple to build
• Front end tag parsing
• Custom field text
formatting
• Single PHP file
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. 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. 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}
10. Strengths
• Front end tag parsing
• Control panel
administration
• Easy upgrade from
plugin
• Process form
submissions
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. Freeform
• Developed by: Solspace
• Custom forms
• Record submissions in DB
• Email notifications
• http://www.solspace.com/software/
detail/freeform/
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. 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. 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/
17. Strengths
• Extend existing tags
• Extend control panel
• Built in settings form -
can be extended
• All through hooks
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. 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. 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
24. Passes data
EE Extension
Hook method
Returns modified data
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. FieldFrame
• Developed by: Brandon
Kelly
• Easily add custom fields
• Integrates with SAEF
• http://brandon-kelly.com/
fieldframe
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. NSM Publish Plus
• Developed by: Newism
• Publishing workflow,
drafts and revisions
• Member publishing
permissions
• http://leevigraham.com/cms-
customisation/expressionengine/
nsm-publish-plus/
29. NSM Publish Plus
• Developed by: Newism
• Publishing workflow,
drafts and revisions
• Member publishing
permissions
• http://leevigraham.com/cms-
customisation/expressionengine/
nsm-publish-plus/
31. Strengths
• Powerful: Can change
every aspect of an install
• Combined strengths of
all the components
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. 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. 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. 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. 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. 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/
39. Developing your
own addons
http://expressionengine.com/docs/development/
http://expressionengine.com/developers/
extension_hooks/
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
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. 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. 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. 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. 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. 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. 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. 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;
}