tailieunhanh - Mastering Joomla! 1.5 Extension and Framework Development phần 3

Tuy nhiên, thông tin chứa đựng trong cuốn sách này được bán mà không có sự bảo đảm, thể hiện rõ ràng hay ngụ ý. Không phải là tác giả, xuất bản Packt, cũng không phải các đại lý hoặc nhà phân phối sẽ được tổ chức chịu trách nhiệm về bất kỳ thiệt hại nào | Chapter 4 For each major entity you should identify the tasks associated with each. You can use the table in the previous section which identified common task and method names to help identify tasks. We have seen how to build models views and controllers but we have yet to see how we actually use them. To get started we need to create a PHP file named after the component in the component s frontend folder and we need to create a PHP file named after the component and prefixed with admin. in the component s backend folder. These files are executed when the component is invoked via the frontend and backend respectively. This example shows how we might implement one of these files Check to ensure this file is included in Joomla defined _JEXEC or die Restricted Access get the controller require_once . instantiate and execute the controller controller new MyextensionController controller- execute JRequest getCmd task display redirect controller- redirect You will often find that these files are relatively simple. In the above example we get the controller class file instantiate a new controller execute the task and redirect the browser. The redirect method will only redirect the browser if a redirect URI has been set use setRedirect to set a redirect URI and optionally a message. We can do far more with these files if we wish but often we do not need to generally it is better to keep the processing encapsulated in controllers. It is common practice to use multiple controllers one for each entity. These are generally stored in a folder called controllers in files named after the entity. Each controller class is named after the entity and prefixed with MyextensionController. When we use multiple controllers we generally use the URI query request value c to determine the controller to instantiate. This demonstrates how we can deal with multiple controllers Check to ensure this file is included in Joomla defined _JEXEC or die Restricted .

TỪ KHÓA LIÊN QUAN