Yii Framework Forum: Accessing other model - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Accessing other model Rate Topic: -----

#1 User is offline   Johannn 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 12-April 10
  • Location:Netherlands

Posted 12 April 2010 - 02:06 AM

I downloaded the extension yii-user and placed it under modules in my website. My website currently contains a few modules one of wich is called landingpage.

I want to use the login and registration provided by the yii-user extension. Since I'm not that familiar with the yii framework yet I basically have no idea how to implement it in my current website.

The extension is installed and works, but as a standalone section, and not implemented in the current landingpage.

Basically what I want to do is include the login.php into the index.php of the landingpage.

Is such a thing possible?
0

#2 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 12 April 2010 - 07:34 AM

Would a redirect to the login page be possible? If not you can try overriding the actions() method to specify that the action 'login' in the landing page module/controller should be loaded from the 'user/login' controller.
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#3 User is offline   Johannn 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 12-April 10
  • Location:Netherlands

Posted 12 April 2010 - 08:24 AM

View PostVince., on 12 April 2010 - 07:34 AM, said:

Would a redirect to the login page be possible? If not you can try overriding the actions() method to specify that the action 'login' in the landing page module/controller should be loaded from the 'user/login' controller.


What I do now is basically this in the layout file:

<body>
<? $this->renderPartial('/_partials/header'); ?>
<? $this->renderPartial('/_partials/login'); ?>
<?= $content; ?>
<? $this->renderPartial('/_partials/footer'); ?>
</body>


The login is always on the website, once logged in something else will be displayed where the login form once was.

So redirecting to the user/login isn't possible as far as I know.

As for overriding the actions() method so that is loads from the user/login module, I have no idea how to do that as my expierence with Yii is very basic atm, only started using it 1 week ago.
0

#4 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 13 April 2010 - 01:55 AM

if your using the CWebUser you can use the isGuest property to determine if the member is logged in or not. The code in your layout will need to be changed accordingly. But since i am not sure what you trying to do i would just display a link to get more details about the Actions feature inside a controller which i hope will be the thing you are looking for:
http://www.yiiframew...ntroller#action
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#5 User is offline   Johannn 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 12-April 10
  • Location:Netherlands

Posted 13 April 2010 - 02:43 AM

Maybe my english isn't that great, I'll try to explain myself a little better:

What I have atm are 2 modules, 1 is called landingpage which will be used for mobile devices and the other module is called user which comes from the extension found here(yii-user).

In order to access the landingpage people have to log in, this is where the user module comes in play. I don't want the user module included in the landingpage because in the future there will be a third module, a normal website. That website will also require a login and with a username and password you'll be able to access both sites.

so the layout file of the landingpage looks as follows:

<body>
  <? $this->renderPartial('/_partials/header'); ?>
  <? $this->renderPartial('/_partials/login'); ?>
  <?= $content; ?>
  <? $this->renderPartial('/_partials/footer'); ?>
</body>


The header and footer files are just basic files with logo's etc.
The $content will render the content of the website as usual.

And the login will render the login form on the website, at least that's the idea. The problem is that the login form I want is in the user module. and I can't seem to access it from within the landingpage module. My idea was to simple include the login.php from the user module, but that's not possible because then you'll miss controllers etc.

So actually I want to render the login.php from the user module within the landingpage module.

And yeah the idea is to later on use the isGuest() to hide to login form and show messages instead.

I hope I made it more clear what I want to do and you got an idea what I try to achieve.
0

#6 User is offline   Vince. 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 432
  • Joined: 29-December 08
  • Location:Los Angeles,CA

Posted 13 April 2010 - 04:54 AM

I assume the login.php your referring is a view file, It it's located under the Yii-user module then you will need to render it by specifying the full path to that file (or maybe try dot syntax it might work) in order to include that in your controller.

Even if you do succeed in embedding the view file inside your controller that doesn't mean you will be able to include the entire login controller login as well. So it's either you will dynamically create the Login controller in your landing page controller by calling CWebApplication::createController() (
http://www.yiiframew...ntroller-detail) which i am not really sure if it's a good approach or event possible and WILL solve your problem, I doubt but you should try. It will basically load the controller and will return the controller instance so you could use that instance for rendering the view and the view will be able to read the right controller instance (which will be the login controller instance and not your controller instance).


Resolve View file: http://www.yiiframew...ViewFile-detail
Vince Gabriel, Lead Developer.
Posted ImagePosted ImagePosted Image
0

#7 User is offline   Johannn 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 12-April 10
  • Location:Netherlands

Posted 13 April 2010 - 05:33 AM

Thanks for your help, gonna give it a shot. Will let you know once I've figured it all out :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users