41
Creating Components without “creating components” Brad Markle @bwmarkle inmotionhosting.c om

Joomla Day MN 2014 - Brad Markle

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: Joomla Day MN 2014 - Brad Markle

Creating Componentswithout “creating components”

Brad Markle@bwmarkle

inmotionhosting.com

Page 2: Joomla Day MN 2014 - Brad Markle

an “extension”

What is a component?

Page 3: Joomla Day MN 2014 - Brad Markle

plugins / modules / components

What is an extension?

Page 4: Joomla Day MN 2014 - Brad Markle

What is an extension?

Components

Plugins

Modules

Page 5: Joomla Day MN 2014 - Brad Markle

Which Components come already installed?

Page 6: Joomla Day MN 2014 - Brad Markle
Page 7: Joomla Day MN 2014 - Brad Markle

But… what if you need

Page 8: Joomla Day MN 2014 - Brad Markle

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

Page 9: Joomla Day MN 2014 - Brad Markle

OPTION 1/4

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

My site needs a _______.

Page 10: Joomla Day MN 2014 - Brad Markle

OPTION 2/4 - Download an extension

My site needs a _______.

Page 11: Joomla Day MN 2014 - Brad Markle
Page 12: Joomla Day MN 2014 - Brad Markle

OPTION 3/4 - Install additional software

My site needs a _______.

Page 13: Joomla Day MN 2014 - Brad Markle
Page 14: Joomla Day MN 2014 - Brad Markle
Page 15: Joomla Day MN 2014 - Brad Markle
Page 16: Joomla Day MN 2014 - Brad Markle

wiki.yourdomain.comyourdomain.com/wiki

store.yourdomain.comyourdomain.com/store

Page 17: Joomla Day MN 2014 - Brad Markle

OPTION 4/4

BUILD IT!

My site needs a _______.

Page 18: Joomla Day MN 2014 - Brad Markle

BUILD IT yourself

● Build a component ● Create atemplate override

Page 19: Joomla Day MN 2014 - Brad Markle

You’re not going to learn it in an hour

Component Development

Page 20: Joomla Day MN 2014 - Brad Markle
Page 21: Joomla Day MN 2014 - Brad Markle

Wha ha ha, excellent.

Oh, you can write PHP?

Page 22: Joomla Day MN 2014 - Brad Markle

Where do they go?

Template Overrides

Page 23: Joomla Day MN 2014 - Brad Markle

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

TEMPLATE_NAME/html/ com_content/ article/default.php

Page 24: Joomla Day MN 2014 - Brad Markle

What are they named?

Template Overrides

Page 25: Joomla Day MN 2014 - Brad Markle

default.php

Applied to all

*******.php

Applied on a case-by-case basis

Page 26: Joomla Day MN 2014 - Brad Markle

How are they activated?

Template Overrides

Page 27: Joomla Day MN 2014 - Brad Markle

default.php

No action needed

*******.php

Edit ArticleOptions

Alternative Layout

Page 28: Joomla Day MN 2014 - Brad Markle

I use this stuff every day

Essential Techniques

Page 29: Joomla Day MN 2014 - Brad Markle

// Get a db connection

$db = JFactory::getDbo();

Page 30: Joomla Day MN 2014 - Brad Markle

id name email username

1 John Smith [email protected] johnsmith

2 Magda Hellman [email protected] magdah

3 Yvonne de Gaulle [email protected] ydegaulle

loadResult()

Page 31: Joomla Day MN 2014 - Brad Markle

loadObject()

id name email username

1 John Smith [email protected] johnsmith

2 Magda Hellman [email protected] magdah

3 Yvonne de Gaulle [email protected] ydegaulle

Page 32: Joomla Day MN 2014 - Brad Markle

loadObjectList()

id name email username

1 John Smith [email protected] johnsmith

2 Magda Hellman [email protected] magdah

3 Yvonne de Gaulle [email protected] ydegaulle

Page 33: Joomla Day MN 2014 - Brad Markle

// get information on the current user

$user = JFactory::getUser();

Page 34: Joomla Day MN 2014 - Brad Markle

Prints human-readable information about a variable

print_r

Page 35: Joomla Day MN 2014 - Brad Markle

// Convert all applicable characters to HTML entities

htmlentities

Page 36: Joomla Day MN 2014 - Brad Markle

<script>// harmful code goes here

</script>

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

&lt;/script&gt;

Page 37: Joomla Day MN 2014 - Brad Markle

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

Page 38: Joomla Day MN 2014 - Brad Markle

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

addslashes

Page 39: Joomla Day MN 2014 - Brad Markle

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

Ya’ll’)

Page 40: Joomla Day MN 2014 - Brad Markle

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

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

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

Page 41: Joomla Day MN 2014 - Brad Markle

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

Live Demonstration