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

2012-09-09 Thread Greg Skerman
You can implement Auth yourself, but the auth component does alot of the
heavy lifting for you - unless you have a specific reason for implementing
it yourself I would recommend using the component shipped with the
framework.

As an experiment, try *removing* the security component from the users
controller and see if your login form then starts to work.

The homepage will likely be driven by the PagesController shipped with the
framework (if you are using home.ctp under /View/Pages/)


On Mon, Sep 10, 2012 at 11:33 AM, shyandsy  wrote:

> May I implement Auth by myself?
>
> Actually,I do not know how to write a controller for the homepage.
>
> I used three components in the UsersController.php:
>   public $components = array('Session','Security', 'Cookie');
>
>
> 在 2012年9月9日星期日UTC-5下午8时25分37秒,Greg写道:
>>
>> Why are you doing it that way and not just using the Auth component?
>> Auth component basically magics up all of that stuff for you
>>
>> http://book.cakephp.org/2.0/**en/core-libraries/components/**
>> authentication.html
>>
>> point that at a table with a username and password field and you're set
>> (more or less).
>>
>> I'd suggest perhaps that the security component isn't being turned on by
>> the controller generating the home page - where it looks like it is on the
>> users controller... users controller is expecting the security bits which
>> are not available at the time the form is being generated.
>>
>>
>>
>> On Mon, Sep 10, 2012 at 11:11 AM, shyandsy  wrote:
>>
>>> Pretty sure!
>>>
>>> home.ctp
>>> 
>>> >> echo $this->element('LoginForm');
>>> ?>
>>> .
>>>
>>> element/LoginForm.ctp
>>> >> echo $this->Form->create('User', array('url' => array('controller' =>
>>> 'users', 'action' => 'login')));
>>> echo $this->Form->input('username')**;
>>> echo $this->Form->input('password')**;
>>> echo $this->Form->end('登录系统');
>>> ?>
>>>
>>>
>>> UsersController.php
>>>
>>> public function login()
>>> {
>>> if($this->request->is('post'))
>>>  {
>>> $result = $this->User->**findByUsernameAndPassword(
>>> $this->data['User']['username'**],
>>>  $this->data['User']['password'**]);
>>> if($result)
>>> {
>>>  $credential = Security::generateAuthKey();
>>>  //将凭据更新到数据库
>>>  $this->request->data['User']['**credential'] = $credential;
>>> $this->User->id = $result['User']['id'];
>>>  $this->User->save($this->**request->data);
>>>  $this->Session->setFlash('**登录认证成功');
>>>  //设置cookie
>>> $this->Cookie->write('Users.**username', $this->data['User']['username'*
>>> *]);
>>>  $this->Cookie->write('Users.**credential', $credential);
>>> $this->redirect(array('action'**=>'index'));
>>>  }
>>> else
>>> {
>>> $this->Session->setFlash('**登录认证失败');
>>>  }
>>> }
>>>  }
>>>
>>> 在 2012年9月9日星期日UTC-5下午6时40分34秒,**Greg写道:

 can you post the code?


 On Mon, Sep 10, 2012 at 1:45 AM, shyandsy  wrote:

> It doesn't work.
> The submit can not find the controller.
>
> I compared the different between 127.0.0.1/user/login and  127.0.0.1 .
>
> This is the login form in the login page:
>  accept-charset="utf-8">
>  
> 
>  
>  
> 
>  Username
>  
>  
> 
>  Password
>  
>  
> 
>  
>  
>  
> 
>  
>  
> 
>
> This is the login form element in the homepage
>  accept-charset="utf-8">
>  
> 
>  
> 
>  Username
>  
>  
> 
>  Password
>  
>  
> 
>  
>  
> 
>
> Obviously, The login form in user/login page has been assign some
> staff like token, but element is not.
>
> 在 2012年9月6日星期四UTC-5下午7时10分03秒,**Gr**eg写道:
>>
>> Thats fine.
>>
>> The solution for using elements is fairly straight forward. Build
>> your Controller and your model *as normal* - so your Users controller 
>> has a
>> login method.
>>
>> Next, create a new element under View/Elements called "LoginForm.ctp".
>>
>> The login form would look something like this:
>>
>> >
>> echo $this->Form->create(null, array('url' => array('controller' =>
>> 'Users', 'action' => 'login')));
>> // ... rest of the form
>> echo $this->Form->end('login');
>> ?>
>>
>> back over in your home.ctp file you put this where you want the login
>> form to be visible:
>>
>> > echo $this->element('LoginForm');
>> ?>
>>
>> and you're done - the home page will now have the content from
>> LoginForm.ctp which will correctly submit the form data to the login 
>> action
>> on the Users controller.
>>
>> You can of course then reuse the LoginForm element anywhere you like
>> - say the user navigates directly to /Users/login you could dump the 
>> login
>> form element on that page. Or say you wanted it in the header for every
>>>

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

2012-09-09 Thread shyandsy
May I implement Auth by myself?

Actually,I do not know how to write a controller for the homepage.

I used three components in the UsersController.php:
  public $components = array('Session','Security', 'Cookie');


在 2012年9月9日星期日UTC-5下午8时25分37秒,Greg写道:
>
> Why are you doing it that way and not just using the Auth component?
> Auth component basically magics up all of that stuff for you
>
>
> http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html
>
> point that at a table with a username and password field and you're set 
> (more or less).
>
> I'd suggest perhaps that the security component isn't being turned on by 
> the controller generating the home page - where it looks like it is on the 
> users controller... users controller is expecting the security bits which 
> are not available at the time the form is being generated.
>
>
>
> On Mon, Sep 10, 2012 at 11:11 AM, shyandsy 
> > wrote:
>
>> Pretty sure!
>>
>> home.ctp
>> 
>> > echo $this->element('LoginForm');
>> ?>
>> .
>>
>> element/LoginForm.ctp
>> > echo $this->Form->create('User', array('url' => array('controller' => 
>> 'users', 'action' => 'login')));
>> echo $this->Form->input('username');
>> echo $this->Form->input('password');
>> echo $this->Form->end('登录系统');
>> ?>
>>
>>
>> UsersController.php
>>
>> public function login()
>> {
>> if($this->request->is('post'))
>>  {
>> $result = $this->User->findByUsernameAndPassword(
>> $this->data['User']['username'],
>>  $this->data['User']['password']);
>> if($result)
>> {
>>  $credential = Security::generateAuthKey();
>>  //将凭据更新到数据库
>>  $this->request->data['User']['credential'] = $credential;
>> $this->User->id = $result['User']['id'];
>>  $this->User->save($this->request->data);
>>  $this->Session->setFlash('登录认证成功');
>>  //设置cookie
>> $this->Cookie->write('Users.username', $this->data['User']['username']);
>>  $this->Cookie->write('Users.credential', $credential);
>> $this->redirect(array('action'=>'index'));
>>  }
>> else
>> {
>> $this->Session->setFlash('登录认证失败');
>>  }
>> }
>>  }
>>
>> 在 2012年9月9日星期日UTC-5下午6时40分34秒,Greg写道:
>>>
>>> can you post the code?
>>>
>>>
>>> On Mon, Sep 10, 2012 at 1:45 AM, shyandsy  wrote:
>>>
 It doesn't work.
 The submit can not find the controller.

 I compared the different between 127.0.0.1/user/login and  127.0.0.1 .

 This is the login form in the login page:
 >>> accept-charset="utf-8">
  
 
  
  
 
  Username
  
  
 
  Password
  
  
 
  
  
  
 
  
  
 

 This is the login form element in the homepage
 >>> accept-charset="utf-8">
  
 
  
 
  Username
  
  
 
  Password
  
  
 
  
  
  

 Obviously, The login form in user/login page has been assign some staff 
 like token, but element is not.

 在 2012年9月6日星期四UTC-5下午7时10分03秒,**Greg写道:
>
> Thats fine.
>
> The solution for using elements is fairly straight forward. Build your 
> Controller and your model *as normal* - so your Users controller has a 
> login method.
>
> Next, create a new element under View/Elements called "LoginForm.ctp".
>
> The login form would look something like this:
>
> 
> echo $this->Form->create(null, array('url' => array('controller' => 
> 'Users', 'action' => 'login')));
> // ... rest of the form
> echo $this->Form->end('login');
> ?>
>
> back over in your home.ctp file you put this where you want the login 
> form to be visible:
>
>  echo $this->element('LoginForm');
> ?>
>
> and you're done - the home page will now have the content from 
> LoginForm.ctp which will correctly submit the form data to the login 
> action 
> on the Users controller.
>
> You can of course then reuse the LoginForm element anywhere you like - 
> say the user navigates directly to /Users/login you could dump the login 
> form element on that page. Or say you wanted it in the header for every 
> page, modify the layout to include the element.
>
> You don't *have* to associate every action with a specific view for 
> that controller/action combination - it is often quite beneficial to drop 
> reusable forms into elements so that you can reuse them over and over 
> again. It helps with maintenance as well because if you modify the form 
> element, you are modifying it in all places in your site at once instead 
> of 
> having to go and modify every template/view that contains it.
>
>
> On Fri, Sep 7, 2012 at 8:08 AM, shyandsy  wrote:
>
>> Got it, I already know the difference between reply on here and reply 
>> to your mailbox.
>>
>>
>> 在 2012年9月5日星期三UTC-5上午2时45分34秒,**Gr**eg写道:
>>
>>> You don't use a view. Make an element to start with 

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

2012-09-09 Thread Greg Skerman
Why are you doing it that way and not just using the Auth component?
Auth component basically magics up all of that stuff for you

http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html

point that at a table with a username and password field and you're set
(more or less).

I'd suggest perhaps that the security component isn't being turned on by
the controller generating the home page - where it looks like it is on the
users controller... users controller is expecting the security bits which
are not available at the time the form is being generated.



On Mon, Sep 10, 2012 at 11:11 AM, shyandsy  wrote:

> Pretty sure!
>
> home.ctp
> 
>  echo $this->element('LoginForm');
> ?>
> .
>
> element/LoginForm.ctp
>  echo $this->Form->create('User', array('url' => array('controller' =>
> 'users', 'action' => 'login')));
> echo $this->Form->input('username');
> echo $this->Form->input('password');
> echo $this->Form->end('登录系统');
> ?>
>
>
> UsersController.php
>
> public function login()
> {
> if($this->request->is('post'))
> {
> $result = $this->User->findByUsernameAndPassword(
> $this->data['User']['username'],
> $this->data['User']['password']);
> if($result)
> {
> $credential = Security::generateAuthKey();
>  //将凭据更新到数据库
> $this->request->data['User']['credential'] = $credential;
> $this->User->id = $result['User']['id'];
> $this->User->save($this->request->data);
>  $this->Session->setFlash('登录认证成功');
>  //设置cookie
> $this->Cookie->write('Users.username', $this->data['User']['username']);
> $this->Cookie->write('Users.credential', $credential);
> $this->redirect(array('action'=>'index'));
> }
> else
> {
> $this->Session->setFlash('登录认证失败');
> }
> }
>  }
>
> 在 2012年9月9日星期日UTC-5下午6时40分34秒,Greg写道:
>>
>> can you post the code?
>>
>>
>> On Mon, Sep 10, 2012 at 1:45 AM, shyandsy  wrote:
>>
>>> It doesn't work.
>>> The submit can not find the controller.
>>>
>>> I compared the different between 127.0.0.1/user/login and  127.0.0.1 .
>>>
>>> This is the login form in the login page:
>>> >> accept-charset="utf-8">
>>>  
>>> 
>>>  
>>>  
>>> 
>>>  Username
>>>  
>>>  
>>> 
>>>  Password
>>>  
>>>  
>>> 
>>>  
>>> 
>>>  
>>> 
>>>  
>>>  
>>> 
>>>
>>> This is the login form element in the homepage
>>> >> accept-charset="utf-8">
>>>  
>>> 
>>>  
>>> 
>>>  Username
>>>  
>>>  
>>> 
>>>  Password
>>>  
>>>  
>>> 
>>>  
>>>  
>>> 
>>>
>>> Obviously, The login form in user/login page has been assign some staff
>>> like token, but element is not.
>>>
>>> 在 2012年9月6日星期四UTC-5下午7时10分03秒,**Greg写道:

 Thats fine.

 The solution for using elements is fairly straight forward. Build your
 Controller and your model *as normal* - so your Users controller has a
 login method.

 Next, create a new element under View/Elements called "LoginForm.ctp".

 The login form would look something like this:

 >>>
 echo $this->Form->create(null, array('url' => array('controller' =>
 'Users', 'action' => 'login')));
 // ... rest of the form
 echo $this->Form->end('login');
 ?>

 back over in your home.ctp file you put this where you want the login
 form to be visible:

 >>> echo $this->element('LoginForm');
 ?>

 and you're done - the home page will now have the content from
 LoginForm.ctp which will correctly submit the form data to the login action
 on the Users controller.

 You can of course then reuse the LoginForm element anywhere you like -
 say the user navigates directly to /Users/login you could dump the login
 form element on that page. Or say you wanted it in the header for every
 page, modify the layout to include the element.

 You don't *have* to associate every action with a specific view for
 that controller/action combination - it is often quite beneficial to drop
 reusable forms into elements so that you can reuse them over and over
 again. It helps with maintenance as well because if you modify the form
 element, you are modifying it in all places in your site at once instead of
 having to go and modify every template/view that contains it.


 On Fri, Sep 7, 2012 at 8:08 AM, shyandsy  wrote:

> Got it, I already know the difference between reply on here and reply
> to your mailbox.
>
>
> 在 2012年9月5日星期三UTC-5上午2时45分34秒,**Gr**eg写道:
>
>> You don't use a view. Make an element to start with under
>> views/elements.
>> Call it loginForm.ctp or something.
>>
>> Then define an action in the form helper create call to point it at
>> the right controller/action
>>
>> On Wednesday, September 5, 2012, shyandsy wrote:
>>
>>> Hi,  thanks for your anwser firstly.
>>>
>>> I have tried the method of element.
>>> I can load the login view that were written in the
>>> view/users/login.ctp,
>>> but I do not know how to process the POST req

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

2012-09-09 Thread shyandsy
Pretty sure!

home.ctp

element('LoginForm');
?>
.

element/LoginForm.ctp
Form->create('User', array('url' => array('controller' => 
'users', 'action' => 'login')));
echo $this->Form->input('username');
echo $this->Form->input('password');
echo $this->Form->end('登录系统');
?>


UsersController.php

public function login()
{
if($this->request->is('post'))
{
$result = $this->User->findByUsernameAndPassword(
$this->data['User']['username'],
$this->data['User']['password']);
if($result)
{
$credential = Security::generateAuthKey();
 //将凭据更新到数据库
$this->request->data['User']['credential'] = $credential;
$this->User->id = $result['User']['id'];
$this->User->save($this->request->data);
 $this->Session->setFlash('登录认证成功');
 //设置cookie
$this->Cookie->write('Users.username', $this->data['User']['username']);
$this->Cookie->write('Users.credential', $credential);
$this->redirect(array('action'=>'index'));
}
else
{
$this->Session->setFlash('登录认证失败');
}
}
 }

在 2012年9月9日星期日UTC-5下午6时40分34秒,Greg写道:
>
> can you post the code?
>
>
> On Mon, Sep 10, 2012 at 1:45 AM, shyandsy 
> > wrote:
>
>> It doesn't work.
>> The submit can not find the controller.
>>
>> I compared the different between 127.0.0.1/user/login and  127.0.0.1 .
>>
>> This is the login form in the login page:
>> > accept-charset="utf-8">
>>  
>> 
>>  
>>  
>> 
>>  Username
>>  
>>  
>> 
>>  Password
>>  
>>  
>> 
>>  
>> 
>>  
>> 
>>  
>>  
>> 
>>
>> This is the login form element in the homepage
>> > ="utf-8">
>>  
>> 
>>  
>> 
>>  Username
>>  
>>  
>> 
>>  Password
>>  
>>  
>> 
>>  
>>  
>>  
>>
>> Obviously, The login form in user/login page has been assign some staff 
>> like token, but element is not.
>>
>> 在 2012年9月6日星期四UTC-5下午7时10分03秒,Greg写道:
>>>
>>> Thats fine.
>>>
>>> The solution for using elements is fairly straight forward. Build your 
>>> Controller and your model *as normal* - so your Users controller has a 
>>> login method.
>>>
>>> Next, create a new element under View/Elements called "LoginForm.ctp".
>>>
>>> The login form would look something like this:
>>>
>>> >>
>>> echo $this->Form->create(null, array('url' => array('controller' => 
>>> 'Users', 'action' => 'login')));
>>> // ... rest of the form
>>> echo $this->Form->end('login');
>>> ?>
>>>
>>> back over in your home.ctp file you put this where you want the login 
>>> form to be visible:
>>>
>>> >> echo $this->element('LoginForm');
>>> ?>
>>>
>>> and you're done - the home page will now have the content from 
>>> LoginForm.ctp which will correctly submit the form data to the login action 
>>> on the Users controller.
>>>
>>> You can of course then reuse the LoginForm element anywhere you like - 
>>> say the user navigates directly to /Users/login you could dump the login 
>>> form element on that page. Or say you wanted it in the header for every 
>>> page, modify the layout to include the element.
>>>
>>> You don't *have* to associate every action with a specific view for that 
>>> controller/action combination - it is often quite beneficial to drop 
>>> reusable forms into elements so that you can reuse them over and over 
>>> again. It helps with maintenance as well because if you modify the form 
>>> element, you are modifying it in all places in your site at once instead of 
>>> having to go and modify every template/view that contains it.
>>>
>>>
>>> On Fri, Sep 7, 2012 at 8:08 AM, shyandsy  wrote:
>>>
 Got it, I already know the difference between reply on here and reply 
 to your mailbox.


 在 2012年9月5日星期三UTC-5上午2时45分34秒,**Greg写道:

> You don't use a view. Make an element to start with under 
> views/elements. 
> Call it loginForm.ctp or something. 
>
> Then define an action in the form helper create call to point it at 
> the right controller/action
>
> On Wednesday, September 5, 2012, shyandsy wrote:
>
>> Hi,  thanks for your anwser firstly. 
>>
>> I have tried the method of element.
>> I can load the login view that were written in the 
>> view/users/login.ctp, 
>> but I do not know how to process the POST request by 
>> UsersController.login()?
>>
>> I can not find the detail description on the cookbook 2.0.
>>
>>
>> 在 2012年9月4日星期二UTC-5下午7时09分33秒,**Gr**eg写道:
>>>
>>> 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 wrote:
>

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

2012-09-09 Thread Greg Skerman
can you post the code?


On Mon, Sep 10, 2012 at 1:45 AM, shyandsy  wrote:

> It doesn't work.
> The submit can not find the controller.
>
> I compared the different between 127.0.0.1/user/login and  127.0.0.1 .
>
> This is the login form in the login page:
>  accept-charset="utf-8">
> 
> 
> 
> 
> 
> Username
> 
> 
> 
> Password
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>
> This is the login form element in the homepage
>  ="utf-8">
> 
> 
> 
> 
> Username
> 
> 
> 
> Password
> 
> 
> 
> 
> 
> 
>
> Obviously, The login form in user/login page has been assign some staff
> like token, but element is not.
>
> 在 2012年9月6日星期四UTC-5下午7时10分03秒,Greg写道:
>>
>> Thats fine.
>>
>> The solution for using elements is fairly straight forward. Build your
>> Controller and your model *as normal* - so your Users controller has a
>> login method.
>>
>> Next, create a new element under View/Elements called "LoginForm.ctp".
>>
>> The login form would look something like this:
>>
>> >
>> echo $this->Form->create(null, array('url' => array('controller' =>
>> 'Users', 'action' => 'login')));
>> // ... rest of the form
>> echo $this->Form->end('login');
>> ?>
>>
>> back over in your home.ctp file you put this where you want the login
>> form to be visible:
>>
>> > echo $this->element('LoginForm');
>> ?>
>>
>> and you're done - the home page will now have the content from
>> LoginForm.ctp which will correctly submit the form data to the login action
>> on the Users controller.
>>
>> You can of course then reuse the LoginForm element anywhere you like -
>> say the user navigates directly to /Users/login you could dump the login
>> form element on that page. Or say you wanted it in the header for every
>> page, modify the layout to include the element.
>>
>> You don't *have* to associate every action with a specific view for that
>> controller/action combination - it is often quite beneficial to drop
>> reusable forms into elements so that you can reuse them over and over
>> again. It helps with maintenance as well because if you modify the form
>> element, you are modifying it in all places in your site at once instead of
>> having to go and modify every template/view that contains it.
>>
>>
>> On Fri, Sep 7, 2012 at 8:08 AM, shyandsy  wrote:
>>
>>> Got it, I already know the difference between reply on here and reply to
>>> your mailbox.
>>>
>>>
>>> 在 2012年9月5日星期三UTC-5上午2时45分34秒,**Greg写道:
>>>
 You don't use a view. Make an element to start with under
 views/elements.
 Call it loginForm.ctp or something.

 Then define an action in the form helper create call to point it at the
 right controller/action

 On Wednesday, September 5, 2012, shyandsy wrote:

> Hi,  thanks for your anwser firstly.
>
> I have tried the method of element.
> I can load the login view that were written in the
> view/users/login.ctp,
> but I do not know how to process the POST request by
> UsersController.login()?
>
> I can not find the detail description on the cookbook 2.0.
>
>
> 在 2012年9月4日星期二UTC-5下午7时09分33秒,**Gr**eg写道:
>>
>> 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 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 -
>>>
>>> Welcome to my home page.
>>>
>>> 
>>>   News Summary>
>>>   requestAction('/news/**summary'); ?>
>>> 
>>>
>>> 
>>>   requestAction('users/**login'); ?>
>>> 
>>>
>>> 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

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

2012-09-09 Thread shyandsy
It doesn't work.
The submit can not find the controller.

I compared the different between 127.0.0.1/user/login and  127.0.0.1 .

This is the login form in the login page:






Username



Password











This is the login form element in the homepage





Username



Password





 

Obviously, The login form in user/login page has been assign some staff 
like token, but element is not.

在 2012年9月6日星期四UTC-5下午7时10分03秒,Greg写道:
>
> Thats fine.
>
> The solution for using elements is fairly straight forward. Build your 
> Controller and your model *as normal* - so your Users controller has a 
> login method.
>
> Next, create a new element under View/Elements called "LoginForm.ctp".
>
> The login form would look something like this:
>
> 
> echo $this->Form->create(null, array('url' => array('controller' => 
> 'Users', 'action' => 'login')));
> // ... rest of the form
> echo $this->Form->end('login');
> ?>
>
> back over in your home.ctp file you put this where you want the login form 
> to be visible:
>
>  echo $this->element('LoginForm');
> ?>
>
> and you're done - the home page will now have the content from 
> LoginForm.ctp which will correctly submit the form data to the login action 
> on the Users controller.
>
> You can of course then reuse the LoginForm element anywhere you like - say 
> the user navigates directly to /Users/login you could dump the login form 
> element on that page. Or say you wanted it in the header for every page, 
> modify the layout to include the element.
>
> You don't *have* to associate every action with a specific view for that 
> controller/action combination - it is often quite beneficial to drop 
> reusable forms into elements so that you can reuse them over and over 
> again. It helps with maintenance as well because if you modify the form 
> element, you are modifying it in all places in your site at once instead of 
> having to go and modify every template/view that contains it.
>
>
> On Fri, Sep 7, 2012 at 8:08 AM, shyandsy  >wrote:
>
>> Got it, I already know the difference between reply on here and reply to 
>> your mailbox.
>>
>>
>> 在 2012年9月5日星期三UTC-5上午2时45分34秒,Greg写道:
>>
>>> You don't use a view. Make an element to start with under 
>>> views/elements. 
>>> Call it loginForm.ctp or something. 
>>>
>>> Then define an action in the form helper create call to point it at the 
>>> right controller/action
>>>
>>> On Wednesday, September 5, 2012, shyandsy wrote:
>>>
 Hi,  thanks for your anwser firstly. 

 I have tried the method of element.
 I can load the login view that were written in the 
 view/users/login.ctp, 
 but I do not know how to process the POST request by 
 UsersController.login()?

 I can not find the detail description on the cookbook 2.0.


 在 2012年9月4日星期二UTC-5下午7时09分33秒,**Greg写道:
>
> 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  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 -
>>
>> Welcome to my home page.
>>
>> 
>>   News Summary>
>>   requestAction('/news/**su**mmary'); ?>
>> 
>>
>> 
>>   requestAction('users/**lo**gin'); ?>
>> 
>>
>> 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 fu

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

2012-09-06 Thread Greg Skerman
Thats fine.

The solution for using elements is fairly straight forward. Build your
Controller and your model *as normal* - so your Users controller has a
login method.

Next, create a new element under View/Elements called "LoginForm.ctp".

The login form would look something like this:

Form->create(null, array('url' => array('controller' =>
'Users', 'action' => 'login')));
// ... rest of the form
echo $this->Form->end('login');
?>

back over in your home.ctp file you put this where you want the login form
to be visible:

element('LoginForm');
?>

and you're done - the home page will now have the content from
LoginForm.ctp which will correctly submit the form data to the login action
on the Users controller.

You can of course then reuse the LoginForm element anywhere you like - say
the user navigates directly to /Users/login you could dump the login form
element on that page. Or say you wanted it in the header for every page,
modify the layout to include the element.

You don't *have* to associate every action with a specific view for that
controller/action combination - it is often quite beneficial to drop
reusable forms into elements so that you can reuse them over and over
again. It helps with maintenance as well because if you modify the form
element, you are modifying it in all places in your site at once instead of
having to go and modify every template/view that contains it.


On Fri, Sep 7, 2012 at 8:08 AM, shyandsy  wrote:

> Got it, I already know the difference between reply on here and reply to
> your mailbox.
>
>
> 在 2012年9月5日星期三UTC-5上午2时45分34秒,Greg写道:
>
>> You don't use a view. Make an element to start with under views/elements.
>> Call it loginForm.ctp or something.
>>
>> Then define an action in the form helper create call to point it at the
>> right controller/action
>>
>> On Wednesday, September 5, 2012, shyandsy wrote:
>>
>>> Hi,  thanks for your anwser firstly.
>>>
>>> I have tried the method of element.
>>> I can load the login view that were written in the view/users/login.ctp,
>>> but I do not know how to process the POST request by
>>> UsersController.login()?
>>>
>>> I can not find the detail description on the cookbook 2.0.
>>>
>>>
>>> 在 2012年9月4日星期二UTC-5下午7时09分33秒,**Greg写道:

 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  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 -
>
> Welcome to my home page.
>
> 
>   News Summary>
>   requestAction('/news/**su**mmary'); ?>
> 
>
> 
>   requestAction('users/**lo**gin'); ?>
> 
>
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to cake-php+u...@**
> googlegrou

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

2012-09-06 Thread shyandsy
Got it, I already know the difference between reply on here and reply to 
your mailbox.


在 2012年9月5日星期三UTC-5上午2时45分34秒,Greg写道:
>
> You don't use a view. Make an element to start with under views/elements. 
> Call it loginForm.ctp or something. 
>
> Then define an action in the form helper create call to point it at the 
> right controller/action
>
> On Wednesday, September 5, 2012, shyandsy wrote:
>
>> Hi,  thanks for your anwser firstly. 
>>
>> I have tried the method of element.
>> I can load the login view that were written in the view/users/login.ctp, 
>> but I do not know how to process the POST request by 
>> UsersController.login()?
>>
>> I can not find the detail description on the cookbook 2.0.
>>
>>
>> 在 2012年9月4日星期二UTC-5下午7时09分33秒,Greg写道:
>>>
>>> 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  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 -

 Welcome to my home page.

 
   News Summary>
   requestAction('/news/**summary'); ?>
 

 
   requestAction('users/**login'); ?>
 

 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秒,**M**ark 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...@googlegroups.com.
 To unsubscribe from this group, send email to cake-php+u...@**
 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+unsubscr...@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+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




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

2012-09-06 Thread shyandsy
I am  sorry about that.


在 2012年9月5日星期三UTC-5上午2时45分34秒,Greg写道:
>
> You don't use a view. Make an element to start with under views/elements. 
> Call it loginForm.ctp or something. 
>
> Then define an action in the form helper create call to point it at the 
> right controller/action
>
> On Wednesday, September 5, 2012, shyandsy wrote:
>
>> Hi,  thanks for your anwser firstly. 
>>
>> I have tried the method of element.
>> I can load the login view that were written in the view/users/login.ctp, 
>> but I do not know how to process the POST request by 
>> UsersController.login()?
>>
>> I can not find the detail description on the cookbook 2.0.
>>
>>
>> 在 2012年9月4日星期二UTC-5下午7时09分33秒,Greg写道:
>>>
>>> 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  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 -

 Welcome to my home page.

 
   News Summary>
   requestAction('/news/**summary'); ?>
 

 
   requestAction('users/**login'); ?>
 

 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秒,**M**ark 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...@googlegroups.com.
 To unsubscribe from this group, send email to cake-php+u...@**
 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+unsubscr...@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+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




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

2012-09-05 Thread Greg Skerman
You don't use a view. Make an element to start with under views/elements.
Call it loginForm.ctp or something.

Then define an action in the form helper create call to point it at the
right controller/action

On Wednesday, September 5, 2012, shyandsy wrote:

> Hi,  thanks for your anwser firstly.
>
> I have tried the method of element.
> I can load the login view that were written in the view/users/login.ctp,
> but I do not know how to process the POST request by
> UsersController.login()?
>
> I can not find the detail description on the cookbook 2.0.
>
>
> 在 2012年9月4日星期二UTC-5下午7时09分33秒,Greg写道:
>>
>> 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  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 -
>>>
>>> Welcome to my home page.
>>>
>>> 
>>>   News Summary>
>>>   requestAction('/news/**summary'); ?>
>>> 
>>>
>>> 
>>>   requestAction('users/**login'); ?>
>>> 
>>>
>>> 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秒,**M**ark 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...@googlegroups.com.
>>> To unsubscribe from this group, send email to cake-php+u...@**
>>> 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 'cake-php@googlegroups.com');>
> .
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com  'cake-php%2bunsubscr...@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+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




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

2012-09-04 Thread shyandsy
Hi,  thanks for your anwser firstly. 

I have tried the method of element.
I can load the login view that were written in the view/users/login.ctp, 
but I do not know how to process the POST request by 
UsersController.login()?

I can not find the detail description on the cookbook 2.0.


在 2012年9月4日星期二UTC-5下午7时09分33秒,Greg写道:
>
> 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 
> > 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 -
>>
>> Welcome to my home page.
>>
>> 
>>   News Summary>
>>   requestAction('/news/summary'); ?>
>> 
>>
>> 
>>   requestAction('users/login'); ?>
>> 
>>
>> 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...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> cake-php+u...@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+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




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

2012-09-04 Thread shyandsy
Actually, I can not see the login form that were written in login.ctp 
although I already use the requestAction().
The source code related the problem as below:

UsersController.php:
class UsersController extends AppController
{


public function login()
{
if($this->request->is('post'))
{
$result = $this->User->findByUsernameAndPassword(
$this->data['User']['username'],
$this->data['User']['password']);
if($result)
{
$credential = Security::generateAuthKey();
 //将凭据更新到数据库
$this->request->data['User']['credential'] = $credential;
$this->User->id = $result['User']['id'];
$this->User->save($this->request->data);
 $this->Session->setFlash('登录认证成功');
 //设置cookie
$this->Cookie->write('Users.username', $this->data['User']['username']);
$this->Cookie->write('Users.credential', $credential);
$this->redirect(array('action'=>'index'));
}
else
{
$this->Session->setFlash('登录认证失败');
}
}
}


}

login.ctp
login system
Form->create('User');
echo $this->Form->input('username');
echo $this->Form->input('password');
echo $this->Form->end('登录系统');
?>

home.ctp
requestAction('/users/login');
  var_dump($result);
?>

The result of requestAction is null.
I am sure the login method in UsersController is called, because if I put 
   "return 1;" 
on the first line of login method, the return value of requestAction is 1.

the problem is why the requestAction does not load the login view to the 
homepage?

-- 
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+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




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

2012-09-04 Thread Greg Skerman
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  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 -
>
> Welcome to my home page.
>
> 
>   News Summary>
>   requestAction('/news/summary'); ?>
> 
>
> 
>   requestAction('users/login'); ?>
> 
>
> 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+unsubscr...@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+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




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

2012-09-04 Thread Mark Wratten
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 -

Welcome to my home page.


  News Summary>
  requestAction('/news/summary'); ?>



  requestAction('users/login'); ?>


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+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




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

2012-09-03 Thread shyandsy
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+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




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

2012-09-02 Thread 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+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.




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

2012-08-30 Thread shyandsy
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+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.