


In-depth study of Tasks and views in Joomla, joomlatask_PHP tutorial
In-depth learning of Tasks and views in Joomla, joomlatask
[This article is reproduced from: Mengxi Notes]
Joomla is an excellent CMS system that allows you to quickly complete the construction of a website. It provides components, modules, and templates to meet most of your website needs. Components play an important role in this.
1. Basic knowledge
Component (component) is used to display the main data of the page. Joomla's components are designed using an MVC architecture. When a page request is generated, its URL may include task, view, layout and other information. I am here to discuss this task and view. Generally, if the URL contains task, it will not contain view. This is because Joomla believes that task completes a specific task, such as database operation, validity verification, etc., and view is responsible for display. data. The usual design is that after task processing is completed in the task, the setRedirect method will be called to guide it to a view to display data. In fact, in Joomla, if the task is not specified in the URL, the default task is display.
2. Questions
In the project, Open graphic protocol data needs to be included in the meta data of the page. Open graphic protocol is used to provide social networks with descriptions of data to be shared. If your page is completed through a task, and then you use setRedirect in the task to jump to different views based on the data for authorization verification, and then display the data page after the verification is passed, you may encounter this problem: You need to share For this page, you added Open graphic protocol data to the meta data of this page. When you want to share it to social networking sites such as Facebook, Google, etc., you will find that the data and pictures displayed on the shared page are not the data you want to display on the page. .
3. Solution
The above problem is because the Open graphic protocol data acquisition does not support jumps. If you encounter a jump, you will usually go to the homepage of the website to pick up the data, which is not what we want. The problem is setRedirect. The principle of setRedirect is that the HTML header sent to the browser contains jump instructions. The way to solve the above problem is not to use setRedirect, but to use display. Each JControllerLegacy has a display method. You only need to set the view, layout, and other data you want to pass in the input, and then call the display method. Can.
Here is the sample code:
/** * 内部跳转,用于代替setRedirect. 为什么要这样子做呢? * 因为 setRedirect他会发送一个http头到浏览器,让浏览 * 进行跳转,这样一来就多了一个网络请问, 这是其一。最 * 为主要的是setRedirect在某些不支持浏览器redirect的情况 * 下达不到效果,例如:open graphic protocal * * @param type $view 要显示的view * @param type $layout 要显示的layout, 默认为NULL */ protected function internalRedirect($view, $layout=null){ $this->input->set("view", $view); $this->input->set("layout", $layout); return $this->display(); } public function checkAvailable(){ //其他的业务代码 $this->input->set('tmpl', 'doexam'); return $this->internalRedirect("doexam", $layout); }
The above code is written in your Controller. The function internalRedirect displays the page by setting the view and layout in $input (this input refers to the input parameter of the url), and then directly calling the display method of JControllerLegecy.
In the checkAvailable method, before calling internalRedirect, other parameters required by the view are also set.
A friend of Mengxi said that he encountered such a problem when building one of his websites. We discussed and analyzed the Joomla implementation code and found that the solution is actually quite easy, as long as you are familiar with Joomla component development. If you have any questions, you can talk to me
I hope this article can solve the problem you encountered.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Recently, many Win11 users have reported that when shutting down, they are prompted that the taskhostwindow task host is executing the shutdown task. So what is going on? Users can enter the Desktop folder under the local registry editor, and then select AutoEndTasks in the right window to set it. Let this site carefully introduce to users the solution to this problem when shutting down. Windows 11 shutdown prompts that the taskhostwindow task host is executing the shutdown task. Solution 1. Use the key combination win key + r key, enter "regedit" and press Enter, as shown in the figure below. 2. Search for [HKEY

The Charm of Learning C Language: Unlocking the Potential of Programmers With the continuous development of technology, computer programming has become a field that has attracted much attention. Among many programming languages, C language has always been loved by programmers. Its simplicity, efficiency and wide application make learning C language the first step for many people to enter the field of programming. This article will discuss the charm of learning C language and how to unlock the potential of programmers by learning C language. First of all, the charm of learning C language lies in its simplicity. Compared with other programming languages, C language

Learn Pygame from scratch: complete installation and configuration tutorial, specific code examples required Introduction: Pygame is an open source game development library developed using the Python programming language. It provides a wealth of functions and tools, allowing developers to easily create a variety of type of game. This article will help you learn Pygame from scratch, and provide a complete installation and configuration tutorial, as well as specific code examples to get you started quickly. Part One: Installing Python and Pygame First, make sure you have

When editing text content in Word, you sometimes need to enter formula symbols. Some guys don’t know how to input the root number in Word, so Xiaomian asked me to share with my friends a tutorial on how to input the root number in Word. Hope it helps my friends. First, open the Word software on your computer, then open the file you want to edit, and move the cursor to the location where you need to insert the root sign, refer to the picture example below. 2. Select [Insert], and then select [Formula] in the symbol. As shown in the red circle in the picture below: 3. Then select [Insert New Formula] below. As shown in the red circle in the picture below: 4. Select [Radical Formula], and then select the appropriate root sign. As shown in the red circle in the picture below:

Title: Learn the main function in Go language from scratch. As a simple and efficient programming language, Go language is favored by developers. In the Go language, the main function is an entry function, and every Go program must contain the main function as the entry point of the program. This article will introduce how to learn the main function in Go language from scratch and provide specific code examples. 1. First, we need to install the Go language development environment. You can go to the official website (https://golang.org

Original author: Minty, encryption KOL Original compilation: Shenchao TechFlow If you know how to use it, Dune is an all-in-one alpha tool. Take your research to the next level with these 20 Dune dashboards. 1. TopHolder Analysis This simple tool developed by @dcfpascal can analyze tokens based on indicators such as holders’ monthly activity, number of unique holders, and wallet profit and loss ratio. Visit link: https://dune.com/dcfpascal/token-holders2. Token Overview Metrics @andrewhong5297 created this dashboard which provides a way to evaluate tokens by analyzing user actions

A closer look at HTTP status code 100: What does it mean? The HTTP protocol is one of the most commonly used protocols in modern Internet applications. It defines the standard specifications required for communication between browsers and web servers. During the process of HTTP request and response, the server will return various types of status codes to the browser to reflect the processing of the request. Among them, HTTP status code 100 is a special status code used to indicate "continue". HTTP status codes consist of three digits, each status code has a specific meaning

1. This lesson mainly explains [1: Alignment Principle]. First, it will be analyzed from daily life, such as buildings, historical sites, etc. 2. [The role of alignment]: Highlight the content relationship and unify the page vision. 3. This lesson starts from [Analysis of actual cases] [Step 1: Delete excessive and inappropriate beautification and special effects; Step 2: Unify fonts and colors]. 4. First change the [Font to Microsoft YaHei] and then [Change the color of the page] to typeset as shown in the picture. 5. Then go to [Drawing of Timeline], insert [Straight Line - Modify Thickness, Color] and then continue to insert [Ring - Close Fill, Turn on Black Stroke] and then [Copy - Reduce Fill Black] [Select Two to Align 】Create a 'button effect' and then type it, the effect is as shown in the figure
