Welcome Guest, Not a member yet? Register   Sign In
route value can be used in URL
#3

(11-21-2020, 01:59 PM)superior Wrote: The only fix for this i could find about this issue is https://stackoverflow.com/a/35290306/8832064, more people struggle with this issue for indexation.

Thanks for replying.

This is how I addressed the issue.

I decided on a convention that the $route first segment should always be different than the class name to be called.

Then I update the class constructor to check the uri_string()

So.. $route['products/get/all'] = "main/getAllProducts";


PHP Code:
class Main extends CI_Controller
{
  public function __construct()
  {
    parent::__construct();
    $controller explode('/'uri_string())[0];
    if ($controller == 'main') {
      //-- take appropriate action
    

This does not work with cached pages as they don't go down this "route"  Cool but I'm okay with that.  Big Grin
Reply


Messages In This Thread
route value can be used in URL - by paulkd - 11-04-2020, 02:50 AM
RE: route value can be used in URL - by superior - 11-21-2020, 01:59 PM
RE: route value can be used in URL - by paulkd - 11-22-2020, 12:25 AM
RE: route value can be used in URL - by superior - 11-23-2020, 03:23 AM
RE: route value can be used in URL - by paulkd - 11-23-2020, 04:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB