Develop advance joomla! MVC Component for version 3
-
Upload
gunjan-patel -
Category
Education
-
view
890 -
download
0
Transcript of Develop advance joomla! MVC Component for version 3
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
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 filenameFile Name should be same asField 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 forHTML select list options.
Get Database Object
Joomla Query Language functions
Looping to create options arrayJHTML 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 NameComponentName 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 PatternFor 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.inigu-IN.com_helloworld.ini----------------------------------------en-GB.com_helloworld.sys.iniGu-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?