KEMBAR78
Develop advance joomla! MVC Component for version 3 | PPTX
Develop Advance Joomla! MVC Component
for version 3.x
Gunjan Patel
Sr. PHP Developer
Joomla! Bug Squad Member
Joomla! SQL Optimisation team coordinator
Google Summer Of Code 2014 Mentor
Joomla! User Network Ahmedabad
Meet my Joomla! Family
gunjan.ce2009@gmail.com
Time to play with the Database
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Create two files:
1. admin/sql/install.mysql.utf8.sql
2. admin/sql/updates/mysql/0.0.6.sql
Important:
#__schemas table will be used
for upgrades
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Adding a new field type: type="helloworld"
Field file path
Field Custom Type:
helloworld
Notice that it was
Before list
Let’s create field at admin/models/fields/helloworld.php
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Parent field type
Same as filename
File Name should be same as
Field type name
Class name prefix
Should be same as filename
Continue with… admin/models/fields/helloworld.php
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Overriding parent class for
HTML select list options.
Get Database Object
Joomla Query Language
functions
Looping to create options array
JHTML options type value text
Display the chosen message from field type in
menu using Database Table
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Create the admin/tables/helloworld.php file
Table Name
Primary Key
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Modify the site/models/helloworld.php file
Return the table instance
Add new getTable function
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Modify the site/models/helloworld.php file
Update getMsg function to get
Message from Database
Get message id from request.
Notice that here we are not using
$_POST or $_GET
Load table data from auto increment id
Update in helloworld.xml
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
ZIP it
Develop Basic Backend
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Create the admin/helloworld.php file
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Create the general controller admin/controller.php file
Set Default view of
component
Component prefix.
Typically name of
component
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Create the view admin/views/helloworlds/view.html.php file
Parent ClassView NameComponent
Name as class prefix
Call Model get Item
function and pagination
function to support
pagination
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Create the layout admin/views/helloworlds/tmpl/default.php file
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Create the sub-layout
admin/views/helloworlds/tmpl/default_head.php file
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Create the sub-layout
admin/views/helloworlds/tmpl/default_body.php file
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Create the sub-layout
admin/views/helloworlds/tmpl/default_foot.php file
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Create the Model admin/models/helloworlds.php file
Parent class for listing
Function of joomla.
getListQuery function
return query object
Review helloworld.xml
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
ZIP it
• Language files naming conventions:
–For components
• en-GB/en-GB.com_helloworld.ini
–For Menus
• en-GB/en-GB.com_helloworld.sys.ini
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Adding Language Translation Files
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Language File Naming Pattern
For Example:
en-GB : Language code for English (UK)
gu-IN : Language code for Gujarati (India)
hn-IN : Language code for Hindi (India)
<language code>-<country code>
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Language File Naming Pattern
For Example:
en-GB : Language code for English (UK)
gu-IN : Language code for Gujarati (India)
hn-IN : Language code for Hindi (India)
<language code>-<country code>
<language code>-<country code>.com_<component_name>.[type].ini
For Example:
en-GB.com_helloworld.ini
gu-IN.com_helloworld.ini
----------------------------------------
en-GB.com_helloworld.sys.ini
Gu-IN.com_helloworld.sys.ini
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Language String Pattern
For Example:
COM_HELLOWORLD="Hello World!"
COM_HELLOWORLD_DESCRIPTION="This is the Hello World description"
COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_TITLE="Hello World"
COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_DESC="This view displays a selected message"
COM_HELLOWORLD_MENU="Hello World!"
<language_key>=“<language_string_value>”
Language File Location Options in
helloworld.xml file
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Language File Naming Pattern
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
or simply in ROOT
Update helloworld.xml
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
ZIP it
Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
Any Questions?

Develop advance joomla! MVC Component for version 3

  • 1.
    Develop Advance Joomla!MVC Component for version 3.x Gunjan Patel Sr. PHP Developer Joomla! Bug Squad Member Joomla! SQL Optimisation team coordinator Google Summer Of Code 2014 Mentor Joomla! User Network Ahmedabad
  • 2.
    Meet my Joomla!Family gunjan.ce2009@gmail.com
  • 3.
    Time to playwith the Database Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
  • 4.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Create two files: 1. admin/sql/install.mysql.utf8.sql 2. admin/sql/updates/mysql/0.0.6.sql Important: #__schemas table will be used for upgrades
  • 5.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Adding a new field type: type="helloworld" Field file path Field Custom Type: helloworld Notice that it was Before list
  • 6.
    Let’s create fieldat admin/models/fields/helloworld.php Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel Parent field type Same as filename File Name should be same as Field type name Class name prefix Should be same as filename
  • 7.
    Continue with… admin/models/fields/helloworld.php Joomla!User Network Ahmedabad Gunjan Patel @ergunjanpatel Overriding parent class for HTML select list options. Get Database Object Joomla Query Language functions Looping to create options array JHTML options type value text
  • 8.
    Display the chosenmessage from field type in menu using Database Table Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
  • 9.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Create the admin/tables/helloworld.php file Table Name Primary Key
  • 10.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Modify the site/models/helloworld.php file Return the table instance Add new getTable function
  • 11.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Modify the site/models/helloworld.php file Update getMsg function to get Message from Database Get message id from request. Notice that here we are not using $_POST or $_GET Load table data from auto increment id
  • 12.
    Update in helloworld.xml Joomla!User Network Ahmedabad Gunjan Patel @ergunjanpatel ZIP it
  • 13.
    Develop Basic Backend Joomla!User Network Ahmedabad Gunjan Patel @ergunjanpatel
  • 14.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Create the admin/helloworld.php file
  • 15.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Create the general controller admin/controller.php file Set Default view of component Component prefix. Typically name of component
  • 16.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Create the view admin/views/helloworlds/view.html.php file Parent ClassView NameComponent Name as class prefix Call Model get Item function and pagination function to support pagination
  • 17.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Create the layout admin/views/helloworlds/tmpl/default.php file
  • 18.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Create the sub-layout admin/views/helloworlds/tmpl/default_head.php file
  • 19.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Create the sub-layout admin/views/helloworlds/tmpl/default_body.php file
  • 20.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Create the sub-layout admin/views/helloworlds/tmpl/default_foot.php file
  • 21.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Create the Model admin/models/helloworlds.php file Parent class for listing Function of joomla. getListQuery function return query object
  • 22.
    Review helloworld.xml Joomla! UserNetwork Ahmedabad Gunjan Patel @ergunjanpatel ZIP it
  • 23.
    • Language filesnaming conventions: –For components • en-GB/en-GB.com_helloworld.ini –For Menus • en-GB/en-GB.com_helloworld.sys.ini Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel Adding Language Translation Files
  • 24.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Language File Naming Pattern For Example: en-GB : Language code for English (UK) gu-IN : Language code for Gujarati (India) hn-IN : Language code for Hindi (India) <language code>-<country code>
  • 25.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Language File Naming Pattern For Example: en-GB : Language code for English (UK) gu-IN : Language code for Gujarati (India) hn-IN : Language code for Hindi (India) <language code>-<country code> <language code>-<country code>.com_<component_name>.[type].ini For Example: en-GB.com_helloworld.ini gu-IN.com_helloworld.ini ---------------------------------------- en-GB.com_helloworld.sys.ini Gu-IN.com_helloworld.sys.ini
  • 26.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Language String Pattern For Example: COM_HELLOWORLD="Hello World!" COM_HELLOWORLD_DESCRIPTION="This is the Hello World description" COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_TITLE="Hello World" COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_DESC="This view displays a selected message" COM_HELLOWORLD_MENU="Hello World!" <language_key>=“<language_string_value>”
  • 27.
    Language File LocationOptions in helloworld.xml file Joomla! User Network Ahmedabad Gunjan Patel @ergunjanpatel
  • 28.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Language File Naming Pattern
  • 29.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel or simply in ROOT
  • 30.
    Update helloworld.xml Joomla! UserNetwork Ahmedabad Gunjan Patel @ergunjanpatel ZIP it
  • 31.
    Joomla! User NetworkAhmedabad Gunjan Patel @ergunjanpatel Any Questions?