how to change joomla without corehacks-joomla-world-conference-2012

Download How to Change Joomla Without Corehacks-joomla-world-conference-2012

If you can't read please download the document

Upload: peter-martin

Post on 29-Oct-2014

381 views

Category:

Documents


4 download

TRANSCRIPT

How to change Joomla without core hacksPeter Martin Joomla World Conference 2012 Website: www.db8.nl Twitter: @pe7er Linkedin: http://linkedin.com/in/pe7erSunday November 18th, 2012

Overview Presentation

Introduction Core Hack Alternatives 1. Template Override 2. Alternative Layouts 3. Language Override 4. Use of Plugins 5. Clone Module 6. Component with own controller 7. Extra Fields 8. Overriding Core classes

Undoing core hacks Questions?

2

Core Hack

3

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 code Core Hack = modification in source code Joomla 3rd party extension4

Core HackDisadvantage of changing core code: Stability

Might give problems with 3rd party extensions Your code changes can be overwritten when you upgrade

Maintainability

5

Core Hack Example: Contact Form

Visitor's IP address is NOT displayed in email6

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

Core Hack Example: Contact Form Result

(until the next Joomla upgrade):

Date: Sat, 17 Aug 2012 15:30:00 +0200 From: 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]8

Eight Alternatives to Core Hacks

9

1. Template override

10

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 the copy

11

Example1 Latest News module Module

displays a list of most recent articles Latest NewsBeginners Getting Help Getting Started Joomla! Options

Change

request: customer wants to include a date!

12

Example1 Latest News module1a. 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.php to /templates/your_template/html/mod_articles_latest/default.php

13

Example1 Latest News module1b. 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: