Welcome Guest, Not a member yet? Register   Sign In
Using MY_Controller problem
#11

[eluser]jedd[/eluser]
[quote author="asylmottaket" date="1257834016"]
The main issue is that nothing works.. Wink
[/quote]

Yes, I can see how that could be a main issue.

Rather than have Base_controller and Backend_controller, why not just have MY_Controller - it's nicely documented in the user guide, lots of people use it, many tutorials refer to it, and (most importantly) it tends to Just Work.

If you're confusing yourself by multiple extensions to the controller class, think of this as nature's way of encouraging you to be less effusive in your usage of the extends feature of PHP.

I'd also suggest that you really really really want to avoid declaring two controller classes in one file. Ever.
#12

[eluser]asylmottaket[/eluser]
Okey. Did I misunderstand what Clip mentioned about:

class MY_Admin extends MY_Controller
{
function __construct()
{
etc.......
}
}

...or is this what I now understand a not so good practise?

Yeah, I used MY_Controller, but I got some issues with the HMVC library and load->view. (The view would only load when controller and view is outside the modules in its original location.
#13

[eluser]jedd[/eluser]
I have no experience with HMVC - but I'd be surprised if there wasn't some coverage of how to get the MY_Controller extension working in its documentation (assuming there's any substantive difference at all).

I don't believe it's good (or even sane) practice to have two classes declared within a single file.
#14

[eluser]asylmottaket[/eluser]
I'll google it. Thanks for answers!

[SOLVED]


Quote Wiredesignz, other thread:

"Note that this is MX_Controller.php when using HMVC."
#15

[eluser]asylmottaket[/eluser]
On thing though..

By extending the Controller, we got code that is executed in every application controller.. but is there a way to only fire some spesific code for some spesific controller?


I mean, fire authentication functionality in the MY_Controller construct only when some admin application controller is used.

Is it a if(uri segment 1 = 'admin') ...do stuff. Or are there smoother ways?
#16

[eluser]Phil Sturgeon[/eluser]
I set an array of allowed controllers in the hooks.php config file, then use that parameter for if(in_array($uri->segment(1)), $params). That is just one of many ways of course.
#17

[eluser]nZac[/eluser]
@asylmottaket

I would use an IF in the MY_Controller... I think a hook would complicate matters. This way it would be very readable in 6 months!




Theme © iAndrew 2016 - Forum software by © MyBB