Cakephp Classroom image

Anil  Bist / Professional / Web Technology

 
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:

 
 
 
image
Anil  Bist

Skills    Cakephp

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (0)