Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

Embed Size (px)

Citation preview

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    1/75

    Core Hacks are evil How to change Joomla withoutcore hacks

    Peter Martin, twitter: @pe7er

    www.joomladay.co.uk, Sat 5th Oct 2013

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    2/75

    Peter Martin joomladagen.nl 20+21 april 2013 2

    Overview Presentation

    >>> Sheets via:www.db8.nl

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    3/75

    Peter Martin joomladagen.nl 20+21 april 2013 3

    A. Core Hack

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    4/75

    4

    Core Hack

    Joomla = Open Source license GNU GPL

    GPL protects freedom & rights of users

    Source code = public

    You can and are allowed to change all Joomla

    codeCore Hack = modification in source code

    Joomla

    3rd party extension

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    5/75

    5

    Core Hack

    Disadvantage of changing core code:

    Stability Might give problems with 3rd party extensions

    Maintainability

    Your code changes can be overwritten when you upgrade

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    6/75

    6

    Core Hack Example: Contact Form

    Visitor's IP address is NOT displayed in email

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    7/757

    Core Hack Example: Contact Form

    Include IP address with email:/components/com_contact/controllers/contact.php

    private function _sendEmail($data, $contact),just under// Prepare email body

    $mail->setBody($body);

    change into:

    $mail->setBody("IP address: ".

    $_SERVER['REMOTE_ADDR']."\n\n".$body);

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    8/758

    Core Hack Example: Contact Form

    Result (until the next Joomla upgrade):

    Date: Sat, 17 Aug 2012 15:30:00 +0200From: Visitor name Reply-To: [Name visitor] To: [email address SuperAdmin of Website]

    IP adres: 127.0.0.1

    This is an enquiry email via http://www.example.com/ from:[Name visitor]

    [Message of visitor]

    mailto:[email protected]:[email protected]
  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    9/75Peter Martin joomladagen.nl 20+21 april 2013 9

    B. Eight Alternatives to Core Hacks

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    10/75Peter Martin joomladagen.nl 20+21 april 2013 10

    1. Template Override

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    11/7511

    1. Template Override

    Template Layout of website

    "Space" for output components & modules

    Components & Modules

    supply their own HTML output to the template Template overrides (since Joomla 1.5)

    Copy HTML output of components / modules & change thecopy

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    12/7512

    Example1 Latest News module

    Module displays a list of most recent articles

    Latest News

    BeginnersGetting HelpGetting Started

    Joomla!Options

    Change request:

    customer wants to include a date!

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    13/7513

    Example1 Latest News module

    1a. Template override:

    Create HTML override folder in your template:/templates/your_template/html/

    Create new folder for module override

    /templates/your_template/html/mod_articles_latest/

    Copy HTML output from /tmpl/ of the module:/modules/mod_articles_latest/tmpl/default.phpto

    /templates/your_template/html/mod_articles_latest/default.php

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    14/7514

    Example1 Latest News module

    1b. Test template override! Add some text & check front-end website

    /templates/your_template/html/mod_articles_latest/default.php

    1c. Analyse useful variables with print_r:

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    15/7515

    Example1 Latest News modulestdClass Object ( [id] => 8 [title] => Beginners [alias] => beginners [title_alias] => [introtext] => If this is your firstJoomla! site or your first web site, you have come to the right place. Joomla will help you get your website up and

    running quickly and easily. Start off using your site by logging in using the administrator account you created whenyou installed Joomla. [checked_out] => 0 [checked_out_time] => 0000-00-00 00:00:00 [catid] => 19 [created] =>2011-01-01 00:00:01 [created_by] => 42 [created_by_alias] => Joomla! [modified] => 2011-12-27 11:10:49[modified_by] => 42 [modified_by_name] => Super User [publish_up] => 2011-01-01 00:00:01 [publish_down] =>0000-00-00 00:00:00 [images] =>{"image_intro":"","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""} [urls] =>{"urla":"","urlatext":"","targeta":"","urlb":"","urlbtext":"","targetb":"","urlc":"","urlctext":"","targetc":""} [attribs] =>{"show_title":"","link_titles":"","show_intro":"","show_category":"","link_category":"","show_parent_category":"","

    link_parent_category":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_icons":"","show_print_icon":"","show_email_icon":"","show_vote":"","show_hits":"","show_noauth":"","alternative_readmore":"","article_layout":"","show_publishing_options":"","show_article_options":"","show_urls_images_backend":"","show_urls_images_frontend":""} [metadata] =>{"robots":"","author":"","rights":"","xreference":""} [metakey] => [metadesc] => [access] => 1 [hits] => 2[xreference] => [featured] => 1 [readmore] => 1488 [state] => 1 [category_title] => Joomla! [category_route] =>sample-data-articles/joomla [category_access] => 1 [category_alias] => joomla [author] => Joomla! [author_email]=> [email protected] [contactid] => [parent_title] => Sample Data-Articles [parent_id] => 14 [parent_route] =>sample-data-articles [parent_alias] => sample-data-articles [rating] => [rating_count] => [published] => 1

    [parents_published] => 1 [alternative_readmore] => [layout] => [params] => JRegistry Object ( [data:protected] =>stdClass Object ( [article_layout] => _:default [show_title] => []

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    16/7516

    Example1 Latest News module

    1d. Add to override $item->created:

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    17/7517

    Example1 Latest News module

    1e. date/time from database in UTC format

    To use Server Time Zone:$config = Jfactory::getConfig();$user = Jfactory::getUser();?>

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    18/7518

    Example1 Latest News module

    Output:

    Latest NewsSaturday 01 January 2011, 01:00:01 - BeginnersSaturday 01 January 2011, 01:00:01 - Getting HelpSaturday 01 January 2011, 01:00:01 - Getting Started

    Saturday 01 January 2011, 01:00:01 - Joomla!Saturday 01 January 2011, 01:00:01 - Options

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    19/75Peter Martin joomladagen.nl 20+21 april 2013 19

    2. Alternative Layouts

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    20/7520

    2. Alternative Layouts

    Alternative Layouts = addition to Template Override = Template Override XTD

    Extra Control Options regarding display

    Extra HTML output files in /templates/html/

    Four types of alternative layouts: Module Component

    Category

    Menu Item

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    21/7521

    2. Alternative Layouts

    Template override file:

    /templates/your_template/html/mod_articles_latest/default.php overrides the HTML output of

    /modules/mod_articles_latest/tmpl/default.php

    Alternative layout: Add other tmpl HTML output files

    to Template Override folder:/templates/your_template/html/mod_articles_latest/

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    22/7522

    2. Alternative Layouts

    Example:

    Rename override (#1from this presentation) default.phpto non-existing tmpl file: layout-with-date.php:

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    23/75Peter Martin joomladagen.nl 20+21 april 2013 23

    3. Language Overrides

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    24/7524

    3. Language Overrides

    Since Joomla 2.5

    Before 2.5: Core hack language files

    Extensions > Language Manager > Overrides

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    25/7525

    3. Language Overrides

    New, e.g. Read more

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    26/7526

    3. Language Overrides

    Read more Read much more

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    27/75

    27

    3. Language Overrides

    Save & Close:

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    28/75

    28

    3. Language Overrides

    Result:

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    29/75

    29

    3. Language Overrides

    Important: [Filter]

    Site / Admin !

    File location override:

    /language/overrides/en-GB.override.ini COM_CONTENT_READ_MORE="Read much more: "

    Note:

    Other languages 3rd party extensions

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    30/75

    Peter Martin joomladagen.nl 20+21 april 2013 30

    4. Use of Plugins

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    31/75

    31

    4. Use of Plugins

    Joomla removes HTML layout In article titles

    In menu item titles

    In breadcrumb

    Water is H2O

    Menu item H2O Water is H2O

    Article title H2O Water is H2O

    Text in article H2O Water is H2O

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    32/75

    32

    4. Use of Plugins

    ReReplacer Nonumber (Peter van Westen)

    Component + System Plugin

    Download: http://www.nonumber.nl/extensions/rereplacer

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    33/75

    33

    4. Use of Plugins

    Start subscript tag Search #sub#

    Replace by

    End subscript tag Search #/sub#

    Replace by

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    34/75

    34

    4. Use of Plugins

    Water is H2O

    Menu itemH#sub#2#/sub#O Water is H2O

    Article title #sub#2#/sub#O Water is H2O

    Text in article H2O Water is H2O

    Checkthe Menu/Article Alias! Menu item, Browser Page Title! Water is H2O

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    35/75

    Peter Martin joomladagen.nl 20+21 april 2013 35

    5. Clone a Module

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    36/75

    36

    5. Clone a Module

    If template override possible, e.g. mod_quickicon

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    37/75

    37

    5. Clone a Module

    Add your own Quick Icon?

    Output of Quick Icon module:/administrator/modules/mod_quickicon/tmpl/default.php

    $html = JHtml::_('icons.buttons', $buttons);?>

    Not possible to use template override...

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    38/75

    38

    5. Clone a Module

    5a. Copy Module

    /administrator/modules/mod_quickicon/to/administrator/modules/mod_quickicon2/

    5b. Rename files mod_quickicon.php mod_quickicon2.php

    mod_quickicon.xml mod_quickicon2.xml

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    39/75

    39

    5. Clone a Module

    5c. Edit mod_quickicon references

    mod_quickicon2.php$buttons = modQuickIcon2Helper::getButtons($params);require JModuleHelper::getLayoutPath('mod_quickicon2', $params->get('layout', 'default'));

    mod_quickicon2.xmlmod_quickicon2mod_quickicon2.php

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    40/75

    40

    5. Clone a Module

    5d. Add to Joomla:

    Extensions > Extension Manager > Discover

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    41/75

    41

    5. Clone a Module

    5e. Add Module mod_quickicon2: Extensions > Module Manager > Filter: administrator

    [New] > mod_quickicon2

    Title: My own Quick Icons

    Position: icon

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    42/75

    42

    5. Clone a Module

    Oops:Fatal error: Cannot redeclare class modQuickIconHelper in/administrator/modules/mod_quickicon2/helper.php on line 18

    5f. Edit helper.php

    /administrator/modules/mod_quickicon2/helper.phpchange the classname:

    abstract class modQuickIconHelper2

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    43/75

    43

    5. Clone a Module

    5g. Add your own array /administrator/modules/mod_quickicon2/helper.php

    array('link' => Jroute::_('index.php?option=com_search'),'image' => 'header/icon-48-search.png',

    'text' => Jtext::_('Search'),'access' => array('core.manage', 'com_search')),

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    44/75

    44

    5. Clone a Module

    5h. Result:

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    45/75

    Peter Martin joomladagen.nl 20+21 april 2013 45

    6. Component with own controller

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    46/75

    46

    6. Component with own controller

    Joomla's contact component: Displays contact details

    Displays contact form

    Retrieves input contact form (check input, send to specified emailaddress)

    However, in email the IP address of the sender ismissing Template override: not possible

    Clone Component: possible, but component = big

    Plugin: maybe possible, but which?

    Add your own controller....

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    47/75

    47

    6. Component with own controller

    Add own controller to component: Put own controller in existing /controllers/ folder of component

    Template override: change hidden variables in form to trigger your owncontroller

    Example:Change com_contactwithout corehacksend IP address in e-mailto website administrator

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    48/75

    48

    6. Component with own controller

    6a. Template override that triggers own controller: Create template override folder /html/com_contact/contact/

    Copy contact form HTML output/components/com_contact/views/contact/tmpl/default_form.php

    to template override folder /html/com_contact/contact/

    Change /templates/your_template/html/com_contact/contact/default_form.php

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    49/75

    49

    6. Component with own controller

    6b. Own controller Copy com_contact controller

    /components/com_contact/controllers/contact.php

    to (file name = 'task' from form in template override)/components/com_contact/controllers/my_own_controller.php

    6c. Change code of your own controller: 6c1. Change Classnaam:

    class ContactControllerContact extends JcontrollerForm

    becomes:

    class ContactControllerMy_own_controller extends JControllerForm

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    50/75

    50

    6. Component with own controller

    6c. Change code of your own controller: 6c2. Ask for model (Contact) with explicit prefix to prevent error:

    Fatal error: Call to a member function getItem() on a non-object in/components/com_contact/controllers/my_own_controller.php on line 38

    In method: public function submit()

    $model = $this->getModel('Contact');

    becomes:

    $model = $this->getModel('Contact','ContactModel');

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    51/75

    51

    6. Component with own controller

    6c. Change code of your own controller: 6c3. Add your own code in method

    private function _sendEmail($data, $contact),just below// Prepare email body

    $mail->setBody($body);

    becomes:

    $mail->setBody("IP address: "._SERVER['REMOTE_ADDR']."\n\n".$body);

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    52/75

    52

    6. Component with own controller

    6d. Result (will survive next Joomla upgrade):

    Date: Sat, 17 Aug 2012 15:30:00 +0200From: Visitor name Reply-To: [Name visitor] To: [email address SuperAdmin of Website]

    IP adres: 127.0.0.1

    This is an enquiry email via http://www.example.com/ from:[Name visitor]

    [Message of visitor]

    mailto:[email protected]:[email protected]
  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    53/75

    Peter Martin joomladagen.nl 20+21 april 2013 53

    7. Plugin Extra fields

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    54/75

    54

    7. Plugin Extra fields

    Joomla runs extensions: Components: URL

    index.php?option=com_content

    Modules: Menu item&menuItem=x

    Plugin listen to events (hooks)Components have hooks

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    55/75

    55

    7. Plugin Extra fields

    Extended User Profile (core, disabled by default) Joomla's core component com_user

    4 profile forms:1. Front-end - User registration form

    2. Front-end - User profile edit form

    3. Back-end - User Manager > Edit a user form4. Back-end - Admin menu > My Profile view form

    User Plugin:Functionality (add fields to those 4 forms):

    Display

    Save Delete

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    56/75

    56

    7. Plugin Extra fields

    Extended User Profile User Plugin:

    Events:

    onContentPrepareData

    onContentPrepareForm

    onUserAfterSave

    onUserAfterDelete

    Documentation: Creating a profile plugin:

    http://docs.joomla.org/Creating_a_profile_plugin

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    57/75

    57

    7. Plugin Extra fields

    Extra fields in articles?

    Joomla's core component com_content3 places to display extra fields:

    1. Front-end - Display extra fields in article

    2. Front-end - Extra fields in article editor form

    3. Back-end - Extra fields in article editor form Content Plugin:

    Functionality (add fields to those 3 places):

    Display

    Save

    Delete

    i fi

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    58/75

    58

    7. Plugin Extra fields

    Extra Article Fields

    Content Plugin:Events:

    onContentPrepareData

    onContentPrepareForm

    onUserAfterSave

    onUserAfterDelete

    onContentPrepare

    Documentation:Adding Extra Fields to article:

    http://docs.joomla.org/Adding_custom_fields_to_the_article_component

    8 O idi C Cl

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    59/75

    Peter Martin joomladagen.nl 20+21 april 2013 59

    8. Overriding Core Classes

    8 O idi C Cl

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    60/75

    60

    8. Overriding Core Classes

    Joomla's core classes are:

    Loaded once Loaded before everything else

    Core classes can be extended (e.g. in your components)

    but there's no override mechanism

    What if you want to add something to a core class sothat all inheritances will have that code?

    8 O idi C Cl

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    61/75

    61

    8. Overriding Core Classes

    Joomla! Programming -

    Mark Dexter & Louis Landry(released April 2012) Page 182-186:

    Using Plugins to

    Override Core Classes

    Documentation:

    http://docs.joomla.org/How_to_override_the_component_mvc_from_the_Joomla%21_core

    8 O idi C Cl

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    62/75

    62

    8. Overriding Core Classes

    In short:

    System Plugins are loaded before 1st event(onBeforeInitialise)

    Plugins can load Classes / plain code

    Create System Plugin that loads your modified core class

    (with include_once) Exception:

    Classes that have already been loadedbefore the System Plugins are imported...

    U d i C H k

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    63/75

    Peter Martin joomladagen.nl 20+21 april 2013 64

    Undoing Core Hacks

    U d i C H k

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    64/75

    65

    Undoing Core Hacks

    Usually Core Hacks are NOT documented

    Analyse code to find Core Hacks: Joomla 2.5 without 3rd party extensions:

    5,586 items, totalling 19.0 MB

    Test site with some 3rd party extensions:

    7,618 items, totalling 42.2 MB

    Good luck!

    U d i C H k

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    65/75

    66

    Undoing Core Hacks

    Use diff, a file comparison utility:

    GUI: Meld (Linux & Mac OSX) GUI: WinMerge (Windows)

    Preparations 1/2: Back-up of website (Use Akeeba backup!)

    Local LAMP stack (LAMP/XAMPP/MAMP/WAMP)

    Restore back-up to two websites using 2 databases: /my-site-with-hack/

    /my-site-without-hack/

    U d i C H k

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    66/75

    67

    Undoing Core Hacks

    Preparations 2/2:

    Download same version of Joomla & unzip Download same versions of 3rd party extensions

    Overwrite all files with Joomla files (except /installation/folder) to

    /my-site-without-hack/ Install (reinstall) 3rd party extensions to

    /my-site-without-hack/

    Result:

    /my-site-without-hack/ now has original(non-Core Hacked) software!

    U d i C H k

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    67/75

    68

    Undoing Core Hacks

    Use diff tool to compare:

    /my-site-with-hack/ /my-site-without-hack/

    U d i C H k

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    68/75

    69

    Undoing Core Hacks

    Undoing Core Hacks

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    69/75

    70

    Undoing Core Hacks

    The

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    70/75

    Peter Martin joomladagen.nl 20+21 april 2013 71

    The

    Conclusion

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    71/75

    72

    Conclusion

    Core Hack = Modification of core files (Joomla or 3 rd party)

    Eight Alternatives to avoid Core Hacks1. Template Override (copy extensions HTML output to your templates /html/ directory and

    change that)

    2. Alternative Layouts

    3. Language Overrides

    4. Use Plugins

    5. Clone Module (copy complete module & change that)

    6. Own controller (add own controller & use template override to trigger your controller)

    7. Extra fields

    8. Overriding Core Classes

    Undoing Core Hacks

    Use diff tools to compare original & modified code

    Conclusion

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    72/75

    73

    Conclusion

    Core Hack don't!

    Changes (hacks) might get lost during upgrade

    Most of the 8 alternatives: Are in fact a hack on a copy

    of Joomla / 3rd party codeAdvantage: modifications won't get overwritten

    with an upgrade

    Disadvantage:

    code improvements won't make itinto the modified copy!

    Questions?

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    73/75

    Peter Martin joomladagen.nl 20+21 april 2013 74

    Questions?

    Questions?

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    74/75

    Peter Martin joomladagen.nl 20+21 april 2013 75

    Questions?

    Presentation available at www.db8.nl

    Peter Martin

    e-mail: info at db8.nl

    website: www.db8.nl

    Twitter: @pe7er

    Used Photos

  • 7/27/2019 Core hacks are evil - How to change Joomla without core hacks - Joomladay UK 2013.odp

    75/75

    Used Photos

    digital dreams - Flavio Takemoto - http://www.sxc.hu/photo/1160561

    Who buys this stuff for a kid? - Jason Antony - http://www.sxc.hu/photo/456502

    Axe - Peter Huys, http://www.sxc.hu/photo/808871

    Photo Frame 9 Billy Alexander, http://www.sxc.hu/photo/1367198

    Bengali Keyborad - Mohammad Jobaed Adnan http://www.sxc.hu/photo/676844

    usb - Vangelis Thomaidis, http://www.sxc.hu/photo/913590

    HiSpeed copier 1 - Marcin Barowski, http://www.sxc.hu/photo/537037

    Game pad - Michal Zacharzewski, http://www.sxc.hu/photo/957040

    EXTRA Warmth - Nicolas Raymond http://www.sxc.hu/photo/971125

    blueprint - Kerem Yucel, http://www.sxc.hu/photo/282237

    Red Plaster - Paul Barker, http://www.sxc.hu/photo/1114174

    signs signs - Jason Antony, http://www.sxc.hu/photo/751034

    Face - Questions - Bob Smith, http://www.sxc.hu/photo/418215