Tuesday, September 4, 2012

Re: How to use two view(controller) in a page??

I'd do it with an element personally. Have the home page retrieve the data from the models in question then pass the resulting data to individual elements...

requestAction is a major performance hit, especially if you are not caching the results...and on the home page as described here you are looking at subjecting your users to 3 calls to the dispatcher (one for pages, one for news, one for users).

You *can* use requestAction and elements together, then cache the element to reduce the hit if you wish.


On Wed, Sep 5, 2012 at 5:06 AM, Mark Wratten <mark@trimar.com> wrote:
I am assuming you have a route that routes to a specific controller/action, e.g. pages controller, index action.
Then in you home page view View/Pages/index.ctp -

<p>Welcome to my home page.</p>

<div id="news-summary">
  <h2>News Summary></h2>
  <?php echo $this->requestAction('/news/summary'); ?>
</div>

<div id="login-form">
  <?php echo $this->requestAction('users/login'); ?>
</div>

Then, in your News controller, create and action - summary, and a view file summary.ctp.
In your Users controller create action login (which should also handle the POST request when the user logs in) and a login.ctp view file.

Then when the home page is rendered, the news summary and login forms will be displayed.

Mark


On Monday, September 3, 2012 8:04:34 PM UTC-4, shyandsy wrote:
could you put some details on, thanks a lot!
Making a home page that includes login and news list.

I can write a view and controller for that job login or news list, but I don't know how to make that things togerther!!


在 2012年9月3日星期一UTC-5上午12时22分41秒,Mark Wratten写道:
Easiest is to use requestAction() in the homepage view.

On Thursday, August 30, 2012 4:26:12 PM UTC-4, shyandsy wrote:
I am kind of new guy on cakePhp. So the description as below:

I hope to provide two function to users in the homepage, login and news. 
The login uses the view login and the controller loginController, and the news uses the news view and newscontroller.
The problem is how to put the two view in the home page.

(apologize, my first language is not English, if you meet some problem about grammar, I will try to fix it)

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 

No comments: