CakePHP Work Note 20110601_ controller access to the remaining controller methods

Source: Internet
Author: User
CakePHP Work Note access other controller methods in 20110601_ controller
Requestaction (string $url, array $options)

This function calls a controller's action from any location and returns data from the action. The $url passed is a cakephp-relative url (/controllername/actionname/params). To pass extra data to the receiving controller action add to the $options array.
You can use Requestaction () to retrieve a fully rendered view by passing ' return ' in the Options:requestaction ($url, Arra Y (' return ')); It is important to note this making a requestaction using ' return ' from a controller method can cause script and CSS tags to does work correctly.

If used without caching requestaction can leads to poor performance. It is the rarely appropriate to use in a controller or model.

Requestaction is the best used in conjunction with (cached) Elements–as A-to-fetch data for an element before rendering. Let's use the example of putting a "latest comments" element in the layout. First we need to create a controller function, that would return the data.
When a action is called through Requestaction $this->params[' requested ') is the set to 1 as an indicator. So checking this can either return the required data else set it a view variable like you normally would. This helps keep things DRY.
Example:
The method of calling Stores_houses in the Air_status controller Shlistdir
function Airscene ()
{
$this->layout = "iframe";
$rs = $this->requestaction ('/stores_houses/shlistdir ');
$this->set (' Test ', $rs);
}


Hide the Sort drop-down menu on the Gridpanel table header

Article Category: Web Front end
Wrote
Add Enablehdmenu:false to the Gridpanel configuration.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.