Download presentation
Presentation is loading. Please wait.
Published byGriselda Shelton Modified over 8 years ago
1
05-412-421: Information Retrieval อาจารย์ ธีภากรณ์ นฤมาณนลิณี
2
05-412-421: Information RetrievalCreating Joomla! Extensions 2 Lecture 7 Creating Joomla! Extensions
3
05-412-421: Information RetrievalCreating Joomla! Extensions 3 Preview Lots of free add-ons (modules, components, templates) are available in the Internet, but they may not be exactly matched to what we need. So, the knowledge on Joomla programming is required for creating extensions Surely, it will involve PHP programming and MySQL database management
4
05-412-421: Information RetrievalCreating Joomla! Extensions 4 Outline Introducing Modules, Component & Plug-Ins Basic approach for creating extensions –Using copy command –Using Wrapper module Advanced approach for creating extensions –Creating your own front-end module –Creating your own back-end module –Creating your own component
5
05-412-421: Information RetrievalCreating Joomla! Extensions 5 Modules, Component & Plug-Ins Source: Joomla: Overview about components, modules, and plug-ins, Joomla: Overview about components, modules, and plug-ins
6
05-412-421: Information RetrievalCreating Joomla! Extensions 6 Outline Introducing Modules, Component & Plug-Ins Basic approach for creating extensions –Using copy command –Using Wrapper module Advanced approach for creating extensions –Creating your own front-end module –Creating your own back-end module –Creating your own component
7
05-412-421: Information RetrievalCreating Joomla! Extensions 7 Using copy command to create a module The copy command from Module Manager allow you to create a new module in the simple manner 1. Tick in this box 2. Click to copy
8
05-412-421: Information RetrievalCreating Joomla! Extensions 8 Using copy command to create a module (cont.) Noticed a prefix “ Copy of …” of the resulted module Exercise: Follow the example above in order to create a new Main Menu (give the name “ Main Menu2 ” ), but put it in the other location on your site, e.g. right Change them upon your needs
9
05-412-421: Information RetrievalCreating Joomla! Extensions 9 Using copy command to create a module (cont.) The copy approach also apply to any module on the administrator screen In the below figure, the “ cpanel ” position refers to Control Panel screen of Admin screen (see next slide)
10
05-412-421: Information RetrievalCreating Joomla! Extensions 10 Control Panel Screen
11
05-412-421: Information RetrievalCreating Joomla! Extensions 11 Outline Introducing Modules, Component & Plug-Ins Basic approach for creating extensions –Using copy command –Using Wrapper module Advanced approach for creating extensions –Creating your own front-end module –Creating your own back-end module –Creating your own component
12
05-412-421: Information RetrievalCreating Joomla! Extensions 12 What ’ s the wrapper? Similar to what the word “ wrap ” means Wrapped page
13
05-412-421: Information RetrievalCreating Joomla! Extensions 13 Wrapper (mod_wrapper) Wrapper module can ease you to bring your existing sites (or html pages actually) to appear inside Joomla This can be done by setting an existing URL and wraping it inside an inline frame (or iFrame) for display within the Joomla site Joomla web site Your existing page
14
05-412-421: Information RetrievalCreating Joomla! Extensions 14 Wrapper: a demo Open Module Manager and select to display only mod_wrapper for clarity
15
05-412-421: Information RetrievalCreating Joomla! Extensions 15 Wrapper: a demo (cont.) Exercise: Create a new wrapper module by using the copy command that we just learned and named it My Test Wrapper
16
05-412-421: Information RetrievalCreating Joomla! Extensions 16 Wrapper: a demo (cont.) 1. Put the URL of a link to desired web page (either internal or ext. to your sites) 2. Try different ticks to see variously different effects
17
05-412-421: Information RetrievalCreating Joomla! Extensions 17 Outline Introducing Modules, Component & Plug-Ins Basic approach for creating extensions –Using copy command –Using Wrapper module Advanced approach for creating extensions –Creating your own front-end module –Creating your own back-end module –Creating your own component
18
05-412-421: Information RetrievalCreating Joomla! Extensions 18 Writing a Front-end Module Goal: Create a simple module –Name: mod_hellofrom –Parameter: location (its value can be set in Module Mgr) –Function: display location along with the welcome message
19
05-412-421: Information RetrievalCreating Joomla! Extensions 19 Understanding Structure of the Module Each module package contains a min. of two files: –a PHP code file holds the execution code of the module display –an XML descriptor file contains all of the installation directives and information about the module holds also the module parameters that can be configured through the Module Manager interface
20
05-412-421: Information RetrievalCreating Joomla! Extensions 20 Preparing a directory & files 1.Create a folder named mod_hellofrom on a local drive 2. Create a file named mod_hellofrom.xml in the /mod_hellofrom folder, and enter the following code:
21
05-412-421: Information RetrievalCreating Joomla! Extensions 21
22
05-412-421: Information RetrievalCreating Joomla! Extensions 22 The PHP code file (cont.) 3. Create a file named mod_hellofrom.php in the /mod_hellofrom folder, and enter the following code: always begin any extension with a check (under the no direct access section) to ensure that the code is being executed by the Joomla system
23
05-412-421: Information RetrievalCreating Joomla! Extensions 23 The PHP code file (cont.) $myLocation variable uses the get() method of the $params object to get the value of the module parameter called location, which was defined earlier in the XML descriptor file $myDateTime is set to a formatted string holding the current system time and date
24
05-412-421: Information RetrievalCreating Joomla! Extensions 24 The PHP code file (cont.) Using the echo() function to output the text to the browser page, but via the JText::_() method Note: Now 2 files have been completely prepared
25
05-412-421: Information RetrievalCreating Joomla! Extensions 25 The PHP code file (cont.) 4. Zip both files into a file named after the module (e.g., mod_hellofrom.zip)
26
05-412-421: Information RetrievalCreating Joomla! Extensions 26 Install our new module For Installing the Zip file, it can be done easily through the module manager
27
05-412-421: Information RetrievalCreating Joomla! Extensions 27 Install our new module (cont.) Success Message will shown to confirm for the success
28
05-412-421: Information RetrievalCreating Joomla! Extensions 28 View our new module by Administrator Using Module Manager and access our new module
29
05-412-421: Information RetrievalCreating Joomla! Extensions 29 View our new module by Administrator (cont.) Exercise: See the result on your site and try to change to different location (e.g. right)
30
05-412-421: Information RetrievalCreating Joomla! Extensions 30 Congratulation!
31
05-412-421: Information RetrievalCreating Joomla! Extensions 31 Outline Introducing Modules, Component & Plug-Ins Basic approach for creating extensions –Using copy command –Using Wrapper module Advanced approach for creating extensions –Creating your own front-end module –Creating your own back-end module –Creating your own component
32
05-412-421: Information RetrievalCreating Joomla! Extensions 32 Example: Writing a Back-end Module Back-end Module or Administrator Module usually help with maintenance and administration of the site So it is never seen by a front-end user because it generally exposes private system information In this example, our back-end module will list content articles that are missing the article metadata, which is useful for Search Engine Note: We will not go in detail here. But you can study the attached code mod_missingmeta for details
33
05-412-421: Information RetrievalCreating Joomla! Extensions 33 Outline Introducing Modules, Component & Plug-Ins Basic approach for creating extensions –Using copy command –Using Wrapper module Advanced approach for creating extensions –Creating your own front-end module –Creating your own back-end module –Creating your own component
34
05-412-421: Information RetrievalCreating Joomla! Extensions 34 Component vs. Module Components are likely to have more advanced feature than Modules, e.g. user interaction to a form A component can have a complete Administrator interface, whereas a module is limited to simple parameter settings The interface for a component is accessible through the Components menu of the Administrator interface
35
05-412-421: Information RetrievalCreating Joomla! Extensions 35 Writing a component Name: com_suggestionbox Parameter: many (see picture) Function: display a form allowing user to provide feedback on visiting. All of the user data will be stored to a database table for later examination by the administrator Goal: Create a simple component
36
05-412-421: Information RetrievalCreating Joomla! Extensions 36 Preparing a directory & files 1.Create a folder named com_suggestionbox on a local drive 2. Create a file named suggestionbox.xml in the /com_suggestionbox folder, and enter the following code:
37
05-412-421: Information RetrievalCreating Joomla! Extensions 37 The XML file
38
05-412-421: Information RetrievalCreating Joomla! Extensions 38 The XML file (cont.) Note: This administration section is important for making this component to be appeared in the list in the Components menu –To provide an access to the specialized interface of the component –To provide a way for verifying if the component is installed
39
05-412-421: Information RetrievalCreating Joomla! Extensions 39 The PHP Code File Check if this parameter has been posted, then begin to process accordingly Use this style so that no table will be created unless it does not exist
40
05-412-421: Information RetrievalCreating Joomla! Extensions 40 Guarantee the uniqueness for each record Enable time & date to be diplayed when it is created 3 input fields Ensure some text will not foul up the insertion routine e.g. the quotation Get IP address of the submitter automatically from the machine
41
05-412-421: Information RetrievalCreating Joomla! Extensions 41 Message to thank users for their submission Or display a blank form if no form variables are detected Ensure to match the current template
42
05-412-421: Information RetrievalCreating Joomla! Extensions 42 The PHP Code File (cont.) Note: Now 2 files have been completely prepared
43
05-412-421: Information RetrievalCreating Joomla! Extensions 43 The PHP code file (cont.) 3. Zip both files into a file named after the module (e.g., com_suggestionbox.zip)
44
05-412-421: Information RetrievalCreating Joomla! Extensions 44 Install our new component For Installing the Zip file, it can be done easily through the module manager
45
05-412-421: Information RetrievalCreating Joomla! Extensions 45 Install our new module (cont.) Success Message will shown to confirm for the success
46
05-412-421: Information RetrievalCreating Joomla! Extensions 46 View our new component by Administrator You may now access the component form the Component menu Note: Nothing to do here, just checking if it works
47
05-412-421: Information RetrievalCreating Joomla! Extensions 47 Access it under the Menus menu Suppose we want to create a menu button (e.g. showing in the Main Menu) so that users can access our component on the web page Open the Main Menu from the Menu Manager and click a new button
48
05-412-421: Information RetrievalCreating Joomla! Extensions 48 Access it under the Menus menu (cont.)
49
05-412-421: Information RetrievalCreating Joomla! Extensions 49 Congratulation!
50
05-412-421: Information RetrievalCreating Joomla! Extensions 50 Reference Dan Rahmel, Beginning Joomla! From Novice to Professional, Springer-Verlag New York, Inc., July 2007 http://www.apress.comhttp://www.apress.com
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.