Công nghệ thông tin
Kinh nghiệm-thủ thuật
Overview of Components - Sơ lược về Com | Overview of Components - Sơ lược về Com |
|
|
|
| Thứ sáu, 23 Tháng một 2007 | ||||||||||
Page 7 of 8 Component Presentation LayerFrom Mambo ManualHere is where the first half of the serious work starts. We need to create a presentation layer to display the html for different events that are going to be triggered by our component. The presentation layer is a file that builds up as we develop additional functionality. Let's start small. Let's examine what we need just to display a list of users allocated to an in/out board. Create a file called admin.mrx_inout.html.php in the /administrator/components/com_mrx_inout directory. Copy the following code into it and then we'll dissect what's happening. Please don't worry about the fact that the line numbers are not sequential. There are just for reference purposes. 1: <?php /* $Id $ */ Looks confusing? Well, it's not too hard. Let's walk you through. Line 15: We wrap the presentation methods in a class. You can call it what you like but the customary convention is HTML_component_name. Line 19: This is the first method we will build into the presentation layer. We've called it listUsers. We pass four arguments to the function. &$rows will be a array of objects that equate to rows in our database table. Notice the ampersand. This means we are passing this array by its reference. If we didn't, then a copy of the array would be passed to the method. If this array took up, for example, 100kb of memory, we would have just added another 100kb to the memory stack. Passing by reference means we work on the original array and is far more memory efficient. &$catlist will be a string of preformatted html for a select list for categories. &$pageNav is an object that helps us with pagination of the list. $option is the option argument passed via the URL or a submitted form. We could hardcode it but, again, it is customary to pass the option around. This makes it easy to cut−and−paste code from other components already built without changing a lot of standard code. Lines 22 & 86: The entire list is wrapped in a HTML form named "adminForm". The toolbar buttons expect this form to exist. Line 23−30: This is a table that displays a heading, the display limit and a drop−down list to filter by category. Line 27: The pageNavigation class has a method called "writeLimitBox". This method handles the display of the drop−down list for the number of records to display on a page. Line 28: We will have already assembled the HTML for the category drop−down list using a number of utility functions (we'll come to that shortly). All you have to do is output the variable. Line 32−39: We have started another table to display the list of users. This code block defines the column headings. Line 35 contains a special checkbox that is used to select or deselect all of the items shown in the list. Newer news items:
Older news items:
|
||||||||||
| Từ điển thuật ngữ |
| Liên kết Webs |
| Album ảnh |
| Why's luyenkim.net |
| Woman Calendar |
| Cà phê chiều thứ 7 |
| Từ điển LạcViệt Online |
| Kulkul's world |
| www.xahoihoctap.net |