Cakephp Classroom image

pankaj
 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13|Last
Lessons:-Controllers

Written in this way, whenever the element is rendered, a request will be made to the controller to get
the data, the data will be processed, and returned. However in accordance with the warning above it’s
best to make use of element caching to prevent needless processing. By modifying the call to element
to look like this:
echo $this->element(’latest_comments’, array(’cache’ => ’+1 hour’));
The requestAction call will not be made while the cached element view file exists and is valid.
In addition, requestAction now takes array based cake style urls:
echo $this->requestAction(
array(’controller’ => ’articles’, ’action’ => ’featured’),
array(’return’)
);
This allows the requestAction call to bypass the usage of Router::url which can increase performance.
The url based arrays are the same as the ones that HtmlHelper::link() uses with one difference
- if you are using named or passed parameters, you must put them in a second array and wrap them
with the correct key. This is because requestAction merges the named args array (requestAction’s 2nd
parameter) with the Controller::params member array and does not explicitly place the named args
array into the key ‘named’; Additional members in the $option array will also be made available in
the requested action’s Controller::params array:
echo $this->requestAction(’/articles/featured/limit:3’);
echo $this->requestAction(’/articles/view/5’);
As an array in the requestAction would then be:
echo $this->requestAction(
array(’controller’ => ’articles’, ’action’ => ’featured’),
array(’named’ => array(’limit’ => 3))
);
echo $this->requestAction(
array(’controller’ => ’articles’, ’action’ => ’view’),
array(’pass’ => array(5))
);
Note: Unlike other places where array urls are analogous to string urls, requestAction treats them
differently.
When using an array url in conjunction with requestAction() you must specify all parameters that you
will need in the requested action. This includes parameters like $this->request->data. In
addition to passing all required parameters, named and pass parameters must be done in the second
array as seen above.
Controller::loadModel(string $modelClass, mixed $id)
The loadModel function comes handy when you need to use a model which is not the controller’s
default model or its associated model:

 
 
 

pankaj

Skills    Cakephp

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)