Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - HMVC version 5.2
#71

[eluser]wiredesignz[/eluser]
[quote author="mark17" date="1216269956"]Somewhere overhere i read some text about ME not working properly when using alternative parents for controllers, the common MY_Controller practice.[/quote]

ME does not prevent you from using Controller sub-classing, provided you don't use the MY_Controller library class. because CI will not load Modular Extensions Controller if MY_Controller is present in application/libraries.

Quote:Also, i prefer using a PHP5 version instead. Though it happens to be a rather young rewrite of the original PHP4 ME. I have searched this topic for things like bugfixes etcetera but didn't find much of interest. It also seems that you still keep the PHP5 version for testers-only, which tells me it is not production ready. Can you shed some light on the progress and the expected release of this nice piece of code?

While the PHP5 version of ME is still quite new (5.0.27) it is being used in production sites. However you can still use 4.2.x quite happily with PHP5 as the two versions have almost the same functionality.
#72

[eluser]mark17[/eluser]
Thanks for your reply.

I guess we cannot use the MY_Model library class either?
I will perform some tests and see if we can use it.
#73

[eluser]wiredesignz[/eluser]
The only issue is with MY_Controller preventing Modular Extensions Controller from loading.
#74

[eluser]a&w[/eluser]
Since I can't use MY_Controller as a front controller I have been attempting to use:

applications/controllers/default_controller.php
Code:
class Default_Controller extends Controller
{
    function Default_Controller()
    {
        debugBreak();
        parent::Controller();
    }
    
    function _remap($page, $content = '', $title = '')
    {
        $method = $this->uri->rsegment(2);
        $value  = $this->uri->rsegment(3);

        //do stuff
    }

coupled with this .htaccess file
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/default_controller/$1 [L]

Works ok, unless I enter my controller name directly, say: mysite/welcome

Which routes me directly to my controller without going through the default_controller. I was thinking to use _remap in that default_controller and have it be the entry point for the site.

I understand that one of the advertised perks is that you can hit any module controller directly via a url, but following one of the earlier suggestions I was trying to funnel all requests through the default_controller.

Any ideas what I'm doing wrong?
#75

[eluser]wiredesignz[/eluser]
Try using routes instead of .htaccess
#76

[eluser]a&w[/eluser]
Thanks, the following appears to work, I guess my .htaccess doesn't work too well huh?

application/config/routes.php
Code:
$route['default_controller'] = "default_controller";
$route['scaffolding_trigger'] = "";

$route['admin'] = 'admin/home';        //re-route admin to admin/home
$route[':any'] = "default_controller"; //re-route anything else to default controller
#77

[eluser]a&w[/eluser]
Well, it's rerouting everything into default_controller, but the _remap function isn't really working any more because the other segments are not available. Any suggestions on the route to use? Sorry to post here, probably doesn't belong in this thread.
#78

[eluser]wiredesignz[/eluser]
Pass the method segment too ie: default_controller/$1
#79

[eluser]a&w[/eluser]
I had tried bunches of things, and didn't want to post all of them, that was one.

attempting to go to domain/site/module/controller/method/something

Code:
//this route
$route['.*'] = 'default_controller/$1';

//OR this route (have same results shown below)
$route[':any'] = 'default_controller/$1';

function _remap($page, $content = '', $title = '')
    {
        //$page = "\$1"
        $module = $this->uri->rsegment(1);//the first segment (module...ok, good)
        $method = $this->uri->rsegment(2);//"\$1";

Code:
//this route
$route['.*'] = 'default_controller/$1';//404 page not found

$route['(:any)'] = 'default_controller/$1';
#80

[eluser]wiredesignz[/eluser]
Parenthesis are required to capture the content, $route['(.*)'] = 'default_controller/$1';

Check the user_guide regarding routes or study up on regex.




Theme © iAndrew 2016 - Forum software by © MyBB