Joomla Day MN 2014 - Brad Markle

Preview:

DESCRIPTION

Learn how to create Joomla components without actually "creating Joomla components"

Citation preview

Creating Componentswithout “creating components”

Brad Markle@bwmarkle

inmotionhosting.com

an “extension”

What is a component?

plugins / modules / components

What is an extension?

What is an extension?

Components

Plugins

Modules

Which Components come already installed?

But… what if you need

● wiki● forum● classifieds● site map● glossary page● support / ticket system

OPTION 1/4

Core hack:Just find the correct php files and edit them

My site needs a _______.

OPTION 2/4 - Download an extension

My site needs a _______.

OPTION 3/4 - Install additional software

My site needs a _______.

wiki.yourdomain.comyourdomain.com/wiki

store.yourdomain.comyourdomain.com/store

OPTION 4/4

BUILD IT!

My site needs a _______.

BUILD IT yourself

● Build a component ● Create atemplate override

You’re not going to learn it in an hour

Component Development

Wha ha ha, excellent.

Oh, you can write PHP?

Where do they go?

Template Overrides

JOOMLA/components/ com_content/views/ article/tmpl/ default.php

TEMPLATE_NAME/html/ com_content/ article/default.php

What are they named?

Template Overrides

default.php

Applied to all

*******.php

Applied on a case-by-case basis

How are they activated?

Template Overrides

default.php

No action needed

*******.php

Edit ArticleOptions

Alternative Layout

I use this stuff every day

Essential Techniques

// Get a db connection

$db = JFactory::getDbo();

id name email username

1 John Smith johnsmith@domain.example johnsmith

2 Magda Hellman magda_h@domain.example magdah

3 Yvonne de Gaulle ydg@domain.example ydegaulle

loadResult()

loadObject()

id name email username

1 John Smith johnsmith@domain.example johnsmith

2 Magda Hellman magda_h@domain.example magdah

3 Yvonne de Gaulle ydg@domain.example ydegaulle

loadObjectList()

id name email username

1 John Smith johnsmith@domain.example johnsmith

2 Magda Hellman magda_h@domain.example magdah

3 Yvonne de Gaulle ydg@domain.example ydegaulle

// get information on the current user

$user = JFactory::getUser();

Prints human-readable information about a variable

print_r

// Convert all applicable characters to HTML entities

htmlentities

<script>// harmful code goes here

</script>

&lt;script&gt;// harmful code goes here

&lt;/script&gt;

<input type=’text’ value=’Howdy ya’ll’ />

// because injections and 1064’s aren’t fun

addslashes

INERT INTO #__table(`id`,`message`)VALUES (null,’Howdy

Ya’ll’)

JRequest::getVar('option');// com_content

JRequest::getVar('view');// article

JRequest::getVar('id');// 1

please work, please work, please work, please work, please work, please work, please work, please work, please work, please work, please work

Live Demonstration

Recommended