Yii Framework Forum: Having Common Controllers For Backend And Frontend - Yii Framework Forum

Jump to content

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

Having Common Controllers For Backend And Frontend Having common controllers for backend and frontend Rate Topic: -----

#1 User is offline   Uttara 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 08-August 13
  • Location:India

Posted 08 August 2013 - 07:14 AM

Hello,

I am creating a project using Yii framework.
I have successfully separated backend and frontend following this article.
Also I am having two different login forms for backend and frontend but using same UserIdentity Component for authentication at both ends.

I want to know how I can use same controllers for both backend and frontend (using this directory structure).
The reason I want to have common controllers is that there's only admin and delete action to which front users have no access. So having two copies of same controllers seems to be redundant.

plz help.

Thanks,
Uttara
0

#2 User is offline   kiran sharma 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 494
  • Joined: 21-May 11
  • Location:India

Posted 08 August 2013 - 11:53 PM

View PostUttara, on 08 August 2013 - 07:14 AM, said:

The reason I want to have common controllers is that there's only admin and delete action to which front users have no access. So having two copies of same controllers seems to be redundant.


If controller is for admin and delete action -and- front user have no access.. .. Then why you want two different controller..??
You can create single controller for Admin side.

By the way you can call (Admin/Back) controller in Front using,

Yii::import('application.controllers.back.XyzController');
$xyzObj =new XyzController();
$xyzObj->xyzFunction();

Thanks,
Kiran Sharma.
0

#3 User is offline   Uttara 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 08-August 13
  • Location:India

Posted 09 August 2013 - 12:10 AM

View Postkiran sharma, on 08 August 2013 - 11:53 PM, said:

[/size]

If controller is for admin and delete action -and- front user have no access.. .. Then why you want two different controller..??
You can create single controller for Admin side.

By the way you can call (Admin/Back) controller in Front using,

Yii::import('application.controllers.back.XyzController');
$xyzObj =new XyzController();
$xyzObj->xyzFunction();



Thanks for replying
If you refer to my another post (similar edited one) 'Common Controllers For Backend And Frontend', my controllers are inside controllers/back and controllers/front
I am having say 10 controllers common to both end, except user controller to which front users don't have access, thats why I don't want to have two copies of same controllers in front and in back.

sorry but where m supposed to use this
Yii::import('application.controllers.back.XyzController');
$xyzObj =new XyzController();
$xyzObj->xyzFunction();


say m having SalesController.php both in front and in back
0

#4 User is offline   kiran sharma 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 494
  • Joined: 21-May 11
  • Location:India

Posted 09 August 2013 - 12:45 AM

View PostUttara, on 09 August 2013 - 12:10 AM, said:

Thanks for replying
I am having say 10 controllers common to both end, except user controller to which front users don't have access, thats why I don't want to have two copies of same controllers in front and in back.


Still can't understand your requirment... We seperate directory structure to seperate our Admin and Front code.
but as you say you had most of common controllers.... Its better to use different controllers for different side (Admin/Front).
If you had most part of common then i think no need to seperate side (Admin/Front).
You just have to use only one side and just differentiate files (action) permission as Admin / User.
..
Thanks,
Kiran Sharma.
0

#5 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,222
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 09 August 2013 - 01:27 AM

I think you were better off following this article which also covers resources shared between front- and backend. If you need an example, have a look at clevertech's YiiBoilerplate.
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
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