2. WHAT IS RAD?
• RAD = Rapid Application Development
• Create apps quickly with very little code
3. WHAT IS FOF?
• FOF = Framework on Framework
• Rapid application development framework for
Joomla
• Not standalone – it extends Joomla
• Aim to not break backwards compatibility
without a clear deprecation and migration
path.
5. WHAT IS FOF?
•
•
•
•
•
D.R.Y. – Don’t Repeat Yourself
Uses Bootstrap & jQuery
Web services. Integrated JSON support
Almost RESTful, not entirely
Hierarchical MVC (HMCV)
– Include the results of component views anywhere
(other views, other component, modules etc)
6. WHO MADE FOF?
• Created by Nicholas Dionysopoulos
• Now over 23 contributors
7. KEY DATES
•
•
•
•
May 2012 – First public release
June 2012 – Bootstrap & jQuery
March 2013 – XML view templates
September 2013 – Added to Joomla 3.2 alpha
8. BENEFITS
• Less code = less bugs
• Less code = quicker to develop
• Automagic stuff to make your life easier
9. WHERE IS FOF USED?
• By Akeeba products
– Akeeba Backup
– Admin Tools
– Akeeba Subscriptions
– Akeeba Ticket System
– Akeeba DocImports
• Now in Joomla 3.2
– Post Installation Messages
12. KEY FEATURES
• Reuse views while respecting template
overrides – loadAnyTemplate() allows you to
load any view
• Media files overrides – effectively create
template overrides for css and js files
• Automatic JSON and CSV in views
– Just add format=json or format=csv
• XML-based views
– You can mix PHP-based and XML-based templates
13. MAGIC FIELDS
• Just add to your database table and all these just
magically work and implement required
functionality
–
–
–
–
–
–
–
–
enabled
created_by
created_on
modified_by
modified_on
locked_by
locked_on
hits
(like state or published)
(like created)
(like modified)
(like checked_out)
(like checked_out_time)
14. WHY FOF?
•
•
•
•
Less than half the files*
Less than half the code*
More functionality
Much lower barrier of entry for new
developer
*based on the example coming up
19. com_helloworld part 9
Language
Files
Lines of code
PHP
19
285
XML
3
89
SQL
2
10
HTML
2
2
Total
26
386
com_yellow (using FOF)
Language
Files
Lines of code
PHP
2
15
XML
6
130
SQL
3
18
HTML
1
1
Total
12
164
20. TIP 1
• Don’t use Joomla 3.2 beta 1 (it has bugs)
• At this stage, Joomla 3.2 alpha 1 is better for
FOF dev
21. TIP 2
• Clear the cache whenever you change table
structure
23. DATABASE
/administrator/components/com_yellow/sql/install/mysql/install.sql
component name
view name (plural)
CREATE TABLE IF NOT EXISTS `#__yellow_items` (
`yellow_item_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`ordering` int(10) NOT NULL DEFAULT '0',
`created_by` bigint(20) NOT NULL DEFAULT '0',
`created_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
magic `modified_by` bigint(20) NOT NULL DEFAULT '0',
fields `modified_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`locked_by` bigint(20) NOT NULL DEFAULT '0',
`locked_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`yellow_item_id`)
) DEFAULT CHARSET=utf8;
id field as per above
view name (singular)
29. LIST VIEW
/administrator/components/com_yellow/views/items/tmpl/form.default.xml
Refer to live demo, couldn’t fit all the code on this page
<header name="title" type="fieldsearchable" sortable="true"
buttons="yes" buttonclass="btn"
/>
<field name="title" type="text"
show_link="true"
url="index.php?option=com_yellow&view=item&id=[ITEM:ID]"
empty_replacement="(no title)"
/>
35. ADD FIELD TO FORM
• ALTER TABLE jos_yellow_items ADD `country`
varchar(255) NOT NULL;
• /administrator/components/com_yellow/views/it
em/tmpl/form.form.xml
<field name="country" type="text"
description="COM_YELLOW_FIELD_COUNTRY_DESC"
label="COM_YELLOW_FIELD_COUNTRY_LABEL"
required="true"
class="inputbox"
size="60"
/>
36. ADD FIELD TO FORM
• /administrator/language/en-GB/enGB.com_yellow.ini
• COM_YELLOW_FIELD_COUNTRY_DESC="What country is this
greeting for? "
• COM_YELLOW_FIELD_COUNTRY_LABEL="Country"
39. JSON FORMAT
• Append &format=json to any view
• /administrator/index.php?option=com_yellow&format
=json
• [{"yellow_item_id":"1","title":"Hello World!","slug":"helloworld","ordering":"0","created_by":"857","created_on":"2013-1013 07:04:35","modified_by":"857","modified_on":"2013-10-13
08:36:13","locked_by":"857","locked_on":"2013-10-13
08:44:12","enabled":"1","country":"Australia"},{"yellow_item_id":"
2","title":"Good bye World!","slug":"good-byeworld","ordering":"0","created_by":"857","created_on":"2013-1013 07:26:43","modified_by":"0","modified_on":"0000-00-00
00:00:00","locked_by":"0","locked_on":"0000-00-00
00:00:00","enabled":"1","country":""}]
40. MIX AND MATCH PHP WITH XML
• /administrator/components/com_yellow/views/it
ems/tmpl/default.php
<?php
defined('_JEXEC') or die();
This bit loads the XML file
$viewTemplate = $this->getRenderedForm();
echo $viewTemplate;
echo '<div class="span12">If you like this extension, please leave a
rating and review on the <a
href="http://extensions.joomla.org/">JED</a>';
44. SIDEBAR MENU
• Built automatically based on views
• In alphabetical order by default, or you can specify the order by
adding
/administrator/components/com_yellow/views/blah/metadata.xml
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<foflib>
<ordering>4</ordering>
</foflib>
<view title="COM_YELLOW_VIEW_BLAH_TITLE">
<message><![CDATA[COM_YELLOW_VIEW_BLAH_DESC]]></message>
</view>
</metadata>
45. SIDEBAR MENU
• Hide view by adding blank file skip.xml
/administrator/components/com_yellow/views/
blah/skip.xml
46. VERSION SPECIFIC VIEW
OVERRIDES
• FOF will automatically search for view template
files (or XML forms) suffixed with the Joomla!
version family or version number
• Joomla! 2.5
– default.j25.php, default.j2.php and default.php
• Joomla! 3.2
– default.j32.php, default.j3.php and default.php
• Also applies to XML forms
– form.default.j25.xml, form.default.j2.xml