Joomla 3 Component programmeren met RAD - Joomladagen 2014

2,802 views
2,702 views

Published on

Het Rapid Application Development (RAD) framework is een nieuw feature in Joomla 3.2.

Een Joomla component is een PHP/MySQL webapplicatie die gebruik maakt van Joomla's framework. In plaats van zelf een database connectie op te hoeven bouwen, kun je Joomla's database object aanspreken. Ook de vormgeving via templates, toegangsniveaus, opbouw van formulieren (JForms) kun je via Joomla's framework laten afhandelen. Dit scheelt veel werk en ontwikkeltijd. Toch kan het nog sneller!

De meeste Joomla componenten bevatten dezelfde functionaliteit:

In de front-end worden lijsten met gegevens uit de database getoond, met een hyperlink naar een pagina met detailweergave.
In de back-end worden vaak lijsten met gegevens uit de database getoond, met een hyperlink naar een formulier waarmee je de gegevens kunt wijzigen en opslaan.
Door gebruik van het Rapid Application Development framework (dat is gebaseerd op FOF (Framework On Framework) kun je die veelvoorkomende functionaliteit met veel minder regels code programmeren.

In deze presentatie laat Peter zien hoe je met RAD een eenvoudig Joomla component kunt bouwen om locaties & categorien te beheren en aan bezoekers (in combinatie met Google Maps) te tonen.

Component beschikbaar op: https://github.com/pe7er/db8locate

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,802
On SlideShare
0
From Embeds
0
Number of Embeds
573
Actions
Shares
0
Downloads
28
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Joomla 3 Component programmeren met RAD - Joomladagen 2014

  1. 1. Joomla 3 Component programmeren met RAD Peter Martin, www.db8.nl. twitter: @pe7er Joomladagen.nl/2014 – 22+23 maart 2014
  2. 2. Joomladagen 2014Joomladagen 2014 Peter Martin ● Joomla website specialist Marketing + Communicatie achtergrond & technische affiniteit ● Vrijwilliger Joomla: ● Global Moderator ● Community Leadership Team ● Open Coffee Nijmegen ● Linux User Group Nijmegen Interesses: ● Open Source Software ● Linux sinds 2007 (Ubuntu → Debian → Arch Linux → Debian) ● Raspberry Pi ● Muziek (Vinyl) ● Filmhuisfilms Website: www.db8.nl – e-mail: peter@db8.nl LinkedIn: http://www.linkedin.com/in/pe7er – Twitter: @pe7er
  3. 3. Joomladagen 2014Joomladagen 2014 Overzicht Presentatie >>> Sheets via: www.db8.nl <<< a)Introductie b)Rapid Application Development (RAD) c)Joomla Component: db8locate d)Fouten repareren e)Vragen? >>> Component via: https://github.com/pe7er/db8locate <<<
  4. 4. Joomladagen 2014Joomladagen 2014 a) Introductie ● Eigen webapplicatie: alles zelf programmeren ● PHP/MySQL/HTML/CSS/JavaScript ● Joomla component: Joomla = Framework ● Gegevens in/uit database – Database object ● Layout – Template ● Rechtenbeheer – Access Control List (ACL) ● MVC → template overrides mogelijk ● Plugins laten ingrijpen op eigen component
  5. 5. Joomladagen 2014Joomladagen 2014 a) Functionaliteit component back-end ● Lijst van categorieën ● Toon lijst van categorieën ● New / Edit één categorie ● Delete categorie(ën) ● Publish/unpublish categorie(ën) ● Formulier van één categorie ● Toon formulier van één categorie ● Save één categorie ● Lijst van items ● Toon lijst van items ● New / Edit één item ● Delete item(s) ● Publish/unpublish item(s) ● Formulier van één item ● Toon formulier van één item ● Save één item
  6. 6. Joomladagen 2014Joomladagen 2014 a) Functionaliteit component front-end ● Toon lijst van categorieën ● Toon details één categorie ● Toon lijst van items ● Toom één item
  7. 7. Joomladagen 2014Joomladagen 2014 b) Rapid Application Development (RAD)
  8. 8. Joomladagen 2014Joomladagen 2014 ● Veel voorkomende functionaliteit code abstraheren ● Conventies ● Don’t Repeat Yourself (DRY) ● Nooku Framework ('Koowa') – Johan Janssens ● Joomlatools extensies (DOCman), Anahita ● Framework on Framework – Nicholas Dionysopoulos ● Basis van Akeeba Backup, Admin Tools etc b) Software Development Framework
  9. 9. Joomladagen 2014Joomladagen 2014 Rapid Application Development (RAD) ● RAD = Framework on Framework (sinds Joomla 3.2) ● Niet stand-alone maar uitbreiding van Joomla! Platform Gebruikt Joomla's MVC classes (uitbreidingen) & lijkt op Joomla's MVC API ● Backwards compatibile ● Minder code → sneller ontwikkelen & minder bugs ● Convention over configuration -> FOF conventies mbt naamgeving van functies / veldnamen in tabellen -> automatisch functionaliteit ● Bootstrap, jQuery, JSON ● Hierarchical MVC (HMCV) - toon component views op andere plaatsen (andere views, componenten, modules)
  10. 10. Joomladagen 2014Joomladagen 2014 1. basis component (back-end) 1.Entry point /administrator/components/com_db8locate/db8locate.php 2.Dispatcher /administrator/components/com_db8locate/fof.xml 3.SQL definitie van database tabel(len) /administrator/components/com_db8locate/sql/install/mysql/install.sql 4.XML installatie manifest /administrator/components/com_db8locate/db8locate.xml 5.View: lijst /administrator/components/com_db8locate/views/items/tmpl/form.default.xml 6.View: formulier /administrator/components/com_db8locate/views/item/tmpl/form.form.xml 7.Taalbestanden /administrator/components/com_db8locate/language/en-GB/ en-GB.com_db8locate.sys.ini + en-GB.com_db8locate.ini
  11. 11. Joomladagen 2014Joomladagen 2014 c) Joomla Component met RAD
  12. 12. Joomladagen 2014Joomladagen 2014 c) Joomla Component met RAD ● Werkomgeving ● Lokale webomgeving (LAMP/XAMP/MAMP) + phpMyAdmin ● Joomla 3.2.x installatie ● Git (software versie beheer) + github.com ● IDE voor PHP (Netbeans/Eclipse/”weapon of choice”)
  13. 13. Joomladagen 2014Joomladagen 2014 “db8 locate” component Doel: Locaties beheren en op Google Map tonen ● Naam: “db8 Locate” ● Componentnaam: com_db8locate ● Database tabelnaam: #__db8locate_items
  14. 14. Joomladagen 2014Joomladagen 2014 1. basis component (back-end)
  15. 15. Joomladagen 2014Joomladagen 2014 1. basis component (back-end) 1.Entry point /administrator/components/com_db8locate/db8locate.php 2.Dispatcher /administrator/components/com_db8locate/fof.xml 3.SQL definitie van database tabel(len) /administrator/components/com_db8locate/sql/install/mysql/install.sql 4.XML installatie manifest /administrator/components/com_db8locate/db8locate.xml 5.View: lijst /administrator/components/com_db8locate/views/items/tmpl/form.default.xml 6.View: formulier /administrator/components/com_db8locate/views/item/tmpl/form.form.xml
  16. 16. Joomladagen 2014Joomladagen 2014 1.1 basis component – entry point /administrator/components/com_db8locate/db8locate.php <?php defined('_JEXEC') or die(); // Load FOF include_once JPATH_LIBRARIES.'/fof/include.php'; // Quit if FOF is not installed if(!defined('FOF_INCLUDED')) { JError::raiseError ('500', 'FOF is not installed'); } FOFDispatcher::getTmpInstance('com_db8locate')->dispatch();
  17. 17. Joomladagen 2014Joomladagen 2014 1.2 basis component – fof dispatcher/administrator/components/com_db8locate/fof.xml ●<?xml version="1.0" encoding="UTF-8"?> ●<fof> ● <backend> ● <dispatcher> ● <option name="default_view">items</option> </dispatcher> ● </backend> ●</fof>
  18. 18. Joomladagen 2014Joomladagen 2014 1.3 basis component – SQL definitie ● Maak SQL installatie bestand: /administrator/components/com_db8locate/ sql/install/mysql/install.sql install.sql bevat: ● CREATE TABLE, tabelnaam in meervoud: #__db8locate_items ● ID field, veldnaam in enkelvoud: componentnaam_enkelvoud-view_id: db8locate_item_id (in Joomla: “id”) ● title ● PRIMARY KEY (`db8locate_item_id`) = ID field
  19. 19. Joomladagen 2014Joomladagen 2014 1.3 basis component – SQL definitie / administrator/components/com_db8locate/sql/install/mysql/install.sql CREATE TABLE IF NOT EXISTS `#__db8locate_items` ( ● `db8locate_item_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, ● `title` varchar(255) NOT NULL, ● PRIMARY KEY (`db8locate_item_id`) ●) DEFAULT CHARSET=utf8;
  20. 20. Joomladagen 2014Joomladagen 2014 1.4 basis component – XML manifest 1/2 /administrator/components/com_db8locate/db8locate.xml <?xml version="1.0" encoding="utf-8"?> <extension version="3.2" type="component" method="upgrade"> <name>db8 locate</name> <author>Peter Martin</author> <creationDate>23 March 2014</creationDate> <copyright>Copyright (C) 2014 Peter Martin / db8.nl</copyright> <license>GNU General Public License version 2</license> <authorEmail>joomla@db8.nl</authorEmail> <version>1.0.1</version> <description>Component to manage and display locations on a Google Map</description> <!-- SQL query files to execute on installation --> <install> ● <sql> ● <file driver="mysql" charset="utf8">sql/install/mysql/install.sql</file> ● <file driver="mysql">sql/install/mysql/install.sql</file> ● ● <file driver="mysqli" charset="utf8">sql/install/mysql/install.sql</file> ● <file driver="mysqli">sql/install/mysql/install.sql</file> ● </sql> ● </install>
  21. 21. Joomladagen 2014Joomladagen 2014 1.4 basis component – XML manifest 2/2 /administrator/components/com_db8locate/db8locate.xml <!-- Administrator back-end section --> <administration> <!-- Administration menu --> <menu view="cpanel">COM_DB8LOCATE</menu> <!-- Back-end files --> <files folder="backend"> <folder>sql</folder> <filename>db8locate.php</filename> <filename>fof.xml</filename> </files> </administration> </extension>
  22. 22. Joomladagen 2014Joomladagen 2014 1.5 basis component – view lijst /administrator/components/com_db8locate/views/items/tmpl/form.default.xml <?xml version="1.0" encoding="UTF-8"?> ● ●<form type="browse" ● show_header="1" ● show_filters="1" ● show_pagination="1" ● norows_placeholder="COM_DB8LOCATE_COMMON_NORECORDS"> ● ● <headerset> ● <header name="db8locate_item_id" type="rowselect" tdwidth="20" /> ● <header name="title" type="fieldsearchable" sortable="true" buttons="yes" buttonclass="btn" /> ● </headerset> ● ● <fieldset name="items"> ● <field name="db8locate_item_id" show_id="true" type="selectrow"/> ● <field name="title" type="text" show_link="true" url="index.php?option=com_db8locate &amp;view=item&amp;id=[ITEM:ID]" empty_replacement="(no title)" /> ● </fieldset> ● ●</form>
  23. 23. Joomladagen 2014Joomladagen 2014 1.6 basis component – view formulier /administrator/components/com_db8locate/views/item/tmpl/form.form.xml <?xml version="1.0" encoding="UTF-8"?> ● ●<form validate="true" serverside_validate="true"> ● ● <fieldset name="basic_configuration" ● label="COM_DB8LOCATE_LOCATION_ITEM_EDIT" ● description="COM_DB8LOCATE_LOCATION_ITEM_EDIT_BASIC_DESC" ● class="span4"> ● ● <field name="title" type="text" ● class="inputbox" ● label="JGLOBAL_TITLE" ● required="true" ● Size="50" /> ● </fieldset> ●</form>
  24. 24. Joomladagen 2014Joomladagen 2014 1. basis component – installatie Via Extensions > Extension Manager > Discover
  25. 25. Joomladagen 2014Joomladagen 2014 1. basis component (back-end) ● Lijst weergave
  26. 26. Joomladagen 2014Joomladagen 2014 1. basis component (back-end) ● Formulier weergave
  27. 27. Joomladagen 2014Joomladagen 2014 1. basis component (back-end) ● Lijstweergave na paar keer new & save
  28. 28. Joomladagen 2014Joomladagen 2014 2. taalbestand
  29. 29. Joomladagen 2014Joomladagen 2014 2. taalbestand sys.ini → kort systeem taalbestand voor gebruik door Joomla Plaats in /language/ map van db8locate component! /administrator/components/com_db8locate/ language/en-GB/en-GB.com_db8locate.sys.ini ● COM_DB8LOCATE="db8 Locate" COM_DB8LOCATE_XML_DESCRIPTION="Component to manage and display locations on a Google Map"
  30. 30. Joomladagen 2014Joomladagen 2014 2. taalbestand .ini → taalbestand voor gebruik in com_db8locate Plaats in /language/ map in component! /administrator/components/com_db8locate/ language/en-GB/en-GB.com_db8locate.ini TIP: “Debug Language” & verzamel “vertaal labels” COM_DB8LOCATE="db8 Locate" COM_DB8LOCATE_TITLE_ITEMS="Location Items" COM_DB8LOCATE_COMMON_NORECORDS="No Location Items" COM_DB8LOCATE_TITLE_ITEMS_EDIT="Edit Location Items" COM_DB8LOCATE_LOCATION_ITEM_EDIT="Location Items" COM_DB8LOCATE_LBL_ITEM_SAVED="Location Item saved" COM_DB8LOCATE_CONFIRM_DELETE="Delete Location Item?"
  31. 31. Joomladagen 2014Joomladagen 2014 2. taalbestand
  32. 32. Joomladagen 2014Joomladagen 2014 3. aan/uitzetten
  33. 33. Joomladagen 2014Joomladagen 2014 3. aan/uitzetten – database veld Veld “enabled” aan databasetabel toevoegen om publicatiestatus op te slaan. ALTER TABLE `#__db8locate_items` ADD `enabled` TINYINT( 3 ) NOT NULL DEFAULT '1';
  34. 34. Joomladagen 2014Joomladagen 2014 3. aan/uitzetten – lijst /administrator/components/com_db8locate/views/items/tmpl/form.default.xml Aan <headerset> toevoegen: ● <header name="enabled" type="published" sortable="true" tdwidth="8%" /> ● ●Aan <fieldset name="items"> toevoegen: ● <field name="enabled" type="published"/> ●
  35. 35. Joomladagen 2014Joomladagen 2014 3. aan/uitzetten
  36. 36. Joomladagen 2014Joomladagen 2014 3. aan/uitzetten – formulier /administrator/components/com_db8locate/views/item/tmpl/form.form.xml Aan <fieldset> toevoegen: ● <field name="enabled" type="list" label="JSTATUS" ● labelclass="todo-label" ● class="inputbox" ● filter="intval" size="1" default="1" > ● <option value="1">JPUBLISHED</option> ● <option value="0">JUNPUBLISHED</option> ●</field> ●
  37. 37. Joomladagen 2014Joomladagen 2014 3. aan/uitzetten – formulier
  38. 38. Joomladagen 2014Joomladagen 2014 4. volgorde
  39. 39. Joomladagen 2014Joomladagen 2014 4. volgorde – database veld Veld “ordering” aan databasetabel toevoegen om volgorde op te slaan. ALTER TABLE `#__db8locate_items` ADD `ordering` INT( 11 ) NOT NULL DEFAULT '0';
  40. 40. Joomladagen 2014Joomladagen 2014 4. volgorde – lijst /administrator/components/com_db8locate/views/items/tmpl/form.default.xml Aan <headerset> toevoegen: ● <header name="ordering" type="ordering" sortable="true" tdwidth="10%" /> ● ●Aan <fieldset name="items"> toevoegen: ● <field name="ordering" type="ordering" labelclass="order"/> ● ●
  41. 41. Joomladagen 2014Joomladagen 2014 4. volgorde
  42. 42. Joomladagen 2014Joomladagen 2014 5. categorieën
  43. 43. Joomladagen 2014Joomladagen 2014 5. categorieën – database veld Veld “catid” aan databasetabel toevoegen om category_id op te slaan. ALTER TABLE `#__db8locate_items` ADD `catid` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0';
  44. 44. Joomladagen 2014Joomladagen 2014 5. categorieën – lijst /administrator/components/com_db8locate/views/items/tmpl/form.default.xml NB: xml bestand bevat hardcoded SQL voor MySQL → moet eigenlijk model Aan <headerset> toevoegen: ● <header name="category" type="category" sortable="true" tdwidth="10%" /> ● ●Aan <fieldset name="items"> toevoegen: <field name="catid" type="sql" translate="false" query="SELECT * FROM #__categories" key_field="id" value_field="title" /> ●
  45. 45. Joomladagen 2014Joomladagen 2014 5. categorieën – lijst
  46. 46. Joomladagen 2014Joomladagen 2014 5. categorieën – formulier /administrator/components/com_db8locate/views/item/tmpl/form.form.xml Aan <fieldset> toevoegen: ● <field name="catid" type="category" ● extension="com_db8locate" ● class="inputbox" ● label="JCATEGORY" ● required="true" ● size="1" /> ●
  47. 47. Joomladagen 2014Joomladagen 2014 5. categorieën – formulier
  48. 48. Joomladagen 2014Joomladagen 2014 5. categorieën – toolbar /administrator/components/com_db8locate/toolbar.php ●<?php defined('_JEXEC') or die(); class Db8locateToolbar extends FOFToolbar { public function Db8locateHelperRenderSubmenu($vName) { return $this->renderSubmenu($vName); } public function renderSubmenu($vName = null) { if (is_null($vName)) { $vName = $this->input->getCmd('view', 'cpanel'); } $this->input->set('view', $vName); parent::renderSubmenu(); $toolbar = FOFToolbar::getAnInstance($this->input->getCmd('option', 'com_db8locate'), $this->config); $toolbar->appendLink(Jtext::_('COM_DB8LOCATE_SUBMENU_CATEGORIES'), 'index.php?option=com_categories&extension=com_db8locate', $vName == 'categories'); } }
  49. 49. Joomladagen 2014Joomladagen 2014 5. categorieën – toolbar
  50. 50. Joomladagen 2014Joomladagen 2014 5. categorieën – toolbar in Category ManagerIn Category Manager voor jouw component, knoppen om terug naar Items van component te gaan: /administrator/components/com_db8locate/helpers/db8locate.php ●<?php ●defined('_JEXEC') or die(); ● ●/** ● * Helper to display db8 locate component submenus in com_categories ● */ ●abstract class Db8locateHelper { ● ● public static function addSubmenu($submenu) { JsubMenuHelper::addEntry(JText::_( 'COM_DB8LOCATE_TITLE_ITEMS'), 'index.php?option=com_db8locate', $submenu == 'locations'); JsubMenuHelper::addEntry(JText::_( 'COM_DB8LOCATE_SUBMENU_CATEGORIES'), 'index.php?option=com_categories&view=categories &extension=com_db8locate', $submenu == 'categories'); ● } ●}
  51. 51. Joomladagen 2014Joomladagen 2014 5. categorieën – Category Manager Klik op “Location Categories”, Resultaat: Warning: Invalid argument supplied for foreach() in /var/www/rad/libraries/cms/helper/content.php on line 121
  52. 52. Joomladagen 2014Joomladagen 2014 6. toegangsniveaus 1. Toegang tot applicatie
  53. 53. Joomladagen 2014Joomladagen 2014 6. toegangsniveaus applicatie 1/2 /administrator/components/com_db8locate/access.xml ●<?xml version="1.0" encoding="utf-8"?> ●<access component="com_db8locate"> ● ●<section name="component"> ● <action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" /> <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" /> ● <action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" /> ● <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" /> ● <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" /> ● <action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" /> ● </section>
  54. 54. Joomladagen 2014Joomladagen 2014 6. toegangsniveaus applicatie 2/2 /administrator/components/com_db8locate/access.xml ● <section name="category"> ● <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" /> ● <action name="core.create" title="JACTION_CREATE" description="COM_CATEGORIES_ACCESS_CREATE_DESC" /> ● <action name="core.delete" title="JACTION_DELETE" description="COM_CATEGORIES_ACCESS_DELETE_DESC" /> ● <action name="core.edit" title="JACTION_EDIT" description="COM_CATEGORIES_ACCESS_EDIT_DESC" /> ● <action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_CATEGORIES_ ACCESS_EDITSTATE_DESC" /> ● </section> ● ●</access>
  55. 55. Joomladagen 2014Joomladagen 2014 6. toegangsniveaus 2. (Front-end) toegang tot database items
  56. 56. Joomladagen 2014Joomladagen 2014 6. toegangsniveaus – lijst
  57. 57. Joomladagen 2014Joomladagen 2014 7. parameters
  58. 58. Joomladagen 2014Joomladagen 2014 7. parameters /administrator/components/com_db8locate/config.xml via Components > db8 locate > categories > [options] ●<?xml version="1.0" encoding="UTF-8"?> ●<config> ● ● <fieldset name="permissions" ● label="JCONFIG_PERMISSIONS_LABEL" ● description="JCONFIG_PERMISSIONS_DESC" > ● ● <field name="rules" ● type="rules" ● label="JCONFIG_PERMISSIONS_LABEL" ● class="inputbox" ● filter="rules" ● component="com_db8locate" ● section="component" /> ● ● </fieldset> ● ●</config>
  59. 59. Joomladagen 2014Joomladagen 2014 8. meertaligheid
  60. 60. Joomladagen 2014Joomladagen 2014 8. meertaligheid – database veld Veld “language” aan databasetabel toevoegen om taalcode op te slaan. ALTER TABLE `#__db8locate_items` ADD `language` CHAR( 7 ) NOT NULL DEFAULT '*';
  61. 61. Joomladagen 2014Joomladagen 2014 8. meertaligheid – lijst /administrator/components/com_db8locate/views/items/tmpl/form.default.xml Aan <headerset> toevoegen: ● <header name="language" type="language" sortable="true" tdwidth="10%" /> ● ● ●Aan <fieldset name="items"> toevoegen: <field name="language" type="text" tdwidth="10%" /> ●
  62. 62. Joomladagen 2014Joomladagen 2014 8. meertaligheid – formulier /administrator/components/com_db8locate/views/item/tmpl/form.form.xml Aan <fieldset> toevoegen: ● <field name="language" type="contentlanguage" label="JFIELD_LANGUAGE_LABEL" > ● <option value="*">JALL</option> ● </field> ● ●
  63. 63. Joomladagen 2014Joomladagen 2014 8. meertaligheid – lijst
  64. 64. Joomladagen 2014Joomladagen 2014 9. “magic fields”
  65. 65. Joomladagen 2014Joomladagen 2014 9. “magic fields” ● Nu in component: enabled (“state”), ordering, ● Ook nog toevoegen aan database: created_by, created_on(“created”), modified_by, modified_on(“modified”), locked_by(“checked_out”), locked_on(“checked_out_time”), hits ● In lijstweergave: created_by & created_on ● In formulierweergave: alle velden
  66. 66. Joomladagen 2014Joomladagen 2014 10. tags
  67. 67. Joomladagen 2014Joomladagen 2014 10. tags #__tags tabel: opslag van tags, bijv: id title 4 Joomla 5 Linux #__contentitem_tag_map tabel: koppeling van content items aan tags type_alias core_content_id content_item_id tag_id type_id com_content.article 1 1 2 1 com_content.article 1 1 3 1 com_content.article 3 2 4 1 com_content.article 3 2 5 1 com_weblinks.weblink 2 1 4 2 com_weblinks.weblink 2 1 5 2
  68. 68. Joomladagen 2014Joomladagen 2014 10. tags – formulier /administrator/components/com_db8locate/views/item/tmpl/form.form.xml Aan <fieldset> toevoegen: ● <field name="tags" type="tag" label="JTAG" description="JTAG_DESC" class="inputbox span12" multiple="true" > </field>
  69. 69. Joomladagen 2014Joomladagen 2014 10. tags Helaas... werkt niet... bug in Joomla t/m versie 3.2.3: Gebruik van com_tags alleen mogelijk indien het component JTable gebruikt.
  70. 70. Joomladagen 2014Joomladagen 2014 11. eigen velden voor db8locate
  71. 71. Joomladagen 2014Joomladagen 2014 11. db8locate – database veld Eigen voor deze applicatie specifieke velden aan databasetabel toevoegen om op te slaan. ALTER TABLE `jos_db8locate_items` ●ADD `location` VARCHAR( 60 ) NOT NULL , ●ADD `address` VARCHAR( 50 ) NOT NULL , ●ADD `postcode` VARCHAR( 12 ) NOT NULL , ●ADD `city` VARCHAR( 50 ) NOT NULL , ●ADD `region` VARCHAR( 50 ) NOT NULL , ●ADD `country` VARCHAR( 50 ) NOT NULL , ●ADD `latitude` VARCHAR( 10 ) NOT NULL , ●ADD `longitude` VARCHAR( 10 ) NOT NULL , ●ADD `website` VARCHAR( 100 ) NOT NULL
  72. 72. Joomladagen 2014Joomladagen 2014 11. db8locate – lijst
  73. 73. Joomladagen 2014Joomladagen 2014 11. db8locate – verdere verbeteringen ● Nieuw SQL installatie script: /administrator/components/com_db8locate/sql/install/mysql/install.sql ● Indien “verplichte velden” niet ingevuld zijn, resulteert “save” in wissen van nog niet opgeslagen velden... ● Edit formulier wordt te lang → in kolommen indelen /administrator/components/com_db8locate/views/item/tmpl/form.form.xml
  74. 74. Joomladagen 2014Joomladagen 2014 12. front-end
  75. 75. Joomladagen 2014Joomladagen 2014 12. front-end – basis component 1.Entry point /components/com_db8locate/db8locate.php 2.View: lijst /components/com_db8locate/views/items/tmpl/form.default.xml /components/com_db8locate/views/items/metadata.xml –> voor menu items 3.View: detailpagina /components/com_db8locate/views/item/tmpl/form.item.xml /components/com_db8locate/views/item/metadata.xml –> voor menu items 4.Language files /components/com_db8locate/language/en-GB/en-GB.com_db8locate.ini
  76. 76. Joomladagen 2014Joomladagen 2014 12. front-end – view lijst /components/com_db8locate/views/items/tmpl/form.default.xml <?xml version="1.0" encoding="UTF-8"?> <form type="browse" show_header="1" show_filters="0" show_pagination="1" show_enabled="1" norows_placeholder="COM_DB8LOCATE_COMMON_NORECORDS" > <headerset> <header name="title" type="fieldsearchable" sortable="true"buttons="true" /> <header name="city" type="fieldsearchable" sortable="true"buttons="false" /> <header name="region" sortable="true"buttons="false" /> <header name="country" sortable="true"buttons="false" tdwidth="20%" /> <header name="category" sortable="false"buttons="false" /> </headerset> <fieldset name="items"> <field name="title" type="text" show_link="true" url="index.php?option=com_db8locate&amp;view=item&amp;id=[ITEM:ID]" class="todoitem" empty_replacement="(no title)" /> <field name="city" type="text" /> <field name="region" type="text" /> <field name="country" type="text" /> <field name="catid" type="sql" translate="false" query="SELECT * FROM #__categories" key_field="id" value_field="title"/> </fieldset> </form>
  77. 77. Joomladagen 2014Joomladagen 2014 12. front-end – view lijst
  78. 78. Joomladagen 2014Joomladagen 2014 12. front-end – view details /components/com_db8locate/views/item/tmpl/form.item.xml <?xml version="1.0" encoding="utf-8"?> ●<form ● type="read"> ● ● <fieldset name="a_single_item" class="item-container form-horizontal"> ● <field name="title" type="text" ● label="COM_DB8LOCATE_TITLE" ● class="db8locate-title-field" ● size="50"/> ● ● <field name="city" type="text" ● label="COM_DB8LOCATE_CITY" ● labelclass="db8locate-field" ● size="20" /> ● ● <field name="website" type="text" ● label="COM_DB8LOCATE_WEBSITE" ● labelclass="db8locate-field" ● size="40" /> ● ● </fieldset> ●</form>
  79. 79. Joomladagen 2014Joomladagen 2014 12. front-end – view details
  80. 80. Joomladagen 2014Joomladagen 2014 13. meer views
  81. 81. Joomladagen 2014Joomladagen 2014 13. meer views Combineren van XML & PHP /components/com_db8locate/views/items/tmpl/default.php en dan form.default.xml ophalen Bijv om te mixen met Google Maps <?php $viewTemplate = $this->getRenderedForm(); echo $viewTemplate; ?>
  82. 82. Joomladagen 2014Joomladagen 2014 13. meer views – mixed php & xml
  83. 83. Joomladagen 2014Joomladagen 2014 13. meer views ● Extra (ingebouwde) uitvoermogelijkheden: &format=csv administrator/index.php?option=com_db8locate&format=csv &format=json administrator/index.php?option=com_db8locate&format=json ● Media files overrides <form lessfiles="media://com_db8locate/css/frontend.less||media://com_db8locate/ css/frontend.css
  84. 84. Joomladagen 2014Joomladagen 2014 d) hulpmiddelen
  85. 85. Joomladagen 2014Joomladagen 2014 Fouten ● Lastiger op te sporen dan bij “gewoon” component! ● Cache!! ● Debuggen ● Bijv back-end error: “An error has occurred. 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY node.lft' at line 4 SQL=SELECT node.id FROM jos_categories AS node, jos_categories AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt AND parent.id = ORDER BY node.lft” kan worden veroorzaakt door fout in front-end! Test: Front-end com_db8locate tijdelijk even hernoemen ● Front-end error: Notice: Undefined variable: form_class in /var/www/rad/libraries/fof/render/strapper.php on line 676 Test: .xml files stapsgewijs geheel opnieuw opbouwen ● print_r($object) / echo $query / die(“stop hier”) ● XDebug?
  86. 86. Joomladagen 2014Joomladagen 2014 Bronnen ● Documentatie https://www.akeebabackup.com/documentation/fof.html ● FOF Mailinglist: https://groups.google.com/forum/#! forum/frameworkonframework ● Source code Github: https://github.com/akeeba/fof ● Voorbeelden: https://github.com/akeeba/todo-fof-example/ https://github.com/akeeba/contactus Akeeba Backup Akeeba Ticket System
  87. 87. Joomladagen 2014Joomladagen 2014 i e
  88. 88. Joomladagen 2014Joomladagen 2014 Vragen? Presentatie beschikbaar via: http://www.db8.nl Component db8locate beschikbaar via: https://github.com/pe7er/db8locate Peter Martin e-mail: info at db8.nl website: www.db8.nl twitter: @pe7er
  89. 89. Joomladagen 2014Joomladagen 2014 Gebruikte foto's ● Speed Typing - Matthew Bowden http://www.sxc.hu/photo/275499 ● Speedometer – Abdulhamid AlFadhly http://www.sxc.hu/photo/1390189 ● Earth: Night Edition - Europe - Sigurd Decroos http://www.sxc.hu/photo/140879 ● Forjados 1 - Albert Lazcano http://www.sxc.hu/photo/626785 ● Bengali Keyborad - Mohammad Jobaed Adnan http://www.sxc.hu/photo/676844 ● Old Light Switches - Paul Cross http://www.sxc.hu/photo/1259922 ● madera en pila 1 - jean froidevaux http://www.sxc.hu/photo/313864 ● Books books books... - Brandon Blinkenberg http://www.sxc.hu/photo/424027 ● Sign 3: forbidden access - Davide Guglielmo http://www.sxc.hu/photo/200982 ● Communications Receiver - John Munsch http://www.sxc.hu/photo/260775 ● Flags of the Baltic Sea countries - Johannes Raitio http://www.sxc.hu/photo/471547 ● Lock - Robert Linder http://www.sxc.hu/photo/1395379 ● Basho Collage 5 - Billy Alexander http://www.sxc.hu/photo/1330749 ● Retro/Vintage TV set - "meltingdog" http://www.sxc.hu/photo/1440150 ● san sebastian views 1 - ibon san martin http://www.sxc.hu/photo/94018 ● Fragile Parcel - Richard Dudley http://www.sxc.hu/photo/1279274 ● Sparks - Hector Landaeta http://www.sxc.hu/photo/1184243 ● Tools - J Boontje http://www.sxc.hu/photo/805571 ● signs signs - Jason Antony http://www.sxc.hu/photo/751034

×