Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having Trouble with Routes that have Search Query in them #40

Open
brianrivet opened this issue Nov 16, 2016 · 0 comments
Open

Having Trouble with Routes that have Search Query in them #40

brianrivet opened this issue Nov 16, 2016 · 0 comments

Comments

@brianrivet
Copy link

Hi,

I'm having trouble sorting out how to write the routes I need. I am using stash along with Resource Router to determine the templates to be used based on a user's logged in user group. I have some pages that are using Low Search to return filtered lists of results. I also have have pages that show details for single entries. The urls I am trying to set up would look like this:

For general listing of announcements:
www.example.com/login/announcements

Paginated general listing of announcements:
www.example.com/login/announcements/P2

filtered listing of announcements:
www.example.com/login/announcements/encryptedquerystringhere

filtered listing of announcements with pagination:
www.example.com/login/announcements/encryptedquerystringhere/P2

announcement detail:
www.example.com/login/announcements/url-title-of-announcement

I'm having a problem where depending on the order I have my code blocks in my config file, I get the wrong pages for either filtered lists or for the announcement details. When I have the route block for the announcement detail first in the config, I get the announcement detail template for both announcement details and for filtered lists. If the route code block for the filtered lists is first I get the filtered list template for filtered lists and for announcement details. I get the fact that the route I have set up is matching both cases, but I'm not sure how to fix it. Here is the code I have in place for the routes:

`'login/announcements' => function($router) {

    if (ee()->session->userdata('group_id') == 3) {
        $router->redirect('login');
    } elseif (ee()->session->userdata('group_id') == 6) {
        $router->setTemplate('login/announcements-customer');
    } elseif (ee()->session->userdata('group_id') == 7) { 
    	$router->setTemplate('login/announcements-rep');
    } elseif (ee()->session->userdata('group_id') == 1)  {
        $router->setTemplate('login/announcements-admin');
    } else {
	    $router->setTemplate('login/announcements-restricted');
    }
},

'login/announcements/:pagination' => function($router) {
    
    if (ee()->session->userdata('group_id') == 3) {
        $router->redirect('login');
    } elseif (ee()->session->userdata('group_id') == 6) {
        $router->setTemplate('login/announcements-customer');
    } elseif (ee()->session->userdata('group_id') == 7) { 
    	$router->setTemplate('login/announcements-rep');
    } elseif (ee()->session->userdata('group_id') == 1)  {
        $router->setTemplate('login/announcements-admin');
    } else {
	    $router->setTemplate('login/announcements-restricted');
    }
},


'login/announcements/:url_title' => function($router) {
    
    if (ee()->session->userdata('group_id') == 3) {
        $router->redirect('login');
    } elseif (ee()->session->userdata('group_id') == 6) {
        $router->setTemplate('login/announcement-detail');
    } elseif (ee()->session->userdata('group_id') == 7) { 
    	$router->setTemplate('login/announcement-detail');
    } elseif (ee()->session->userdata('group_id') == 1)  {
        $router->setTemplate('login/announcement-detail');
    } else {
	    $router->setTemplate('login/announcements-restricted');
    }
},


'login/announcements/:any/:pagination' => function($router) {
    
    if (ee()->session->userdata('group_id') == 3) {
        $router->redirect('login');
    } elseif (ee()->session->userdata('group_id') == 6) {
        $router->setTemplate('login/announcements-customer');
    } elseif (ee()->session->userdata('group_id') == 7) { 
    	$router->setTemplate('login/announcements-rep');
    } elseif (ee()->session->userdata('group_id') == 1)  {
        $router->setTemplate('login/announcements-admin');
    } else {
	    $router->setTemplate('login/announcements-restricted');
    }
},

`

Can you help me to sort out what I need to change to get the results I mentioned above?

Thanks,

Brian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant