joomla day mn 2014 - brad markle
DESCRIPTION
Learn how to create Joomla components without actually "creating Joomla components"TRANSCRIPT
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 [email protected] johnsmith
2 Magda Hellman [email protected] magdah
3 Yvonne de Gaulle [email protected] ydegaulle
loadResult()
loadObject()
id name email username
1 John Smith [email protected] johnsmith
2 Magda Hellman [email protected] magdah
3 Yvonne de Gaulle [email protected] ydegaulle
loadObjectList()
id name email username
1 John Smith [email protected] johnsmith
2 Magda Hellman [email protected] magdah
3 Yvonne de Gaulle [email protected] 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>
<script>// harmful code goes here
</script>
<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