Jump to content

conditional url segments


bwakad
 Share

Recommended Posts

I use sort values via input-> so that this part always stays at the end of the url

the link is for example: $currentUrl.'?sort=name';

Since I also use segments to catch a specific field to search on, I had to change the ?sort url.

This is why I used the urlSegmentsStr code below (found on a post from Martijn):

    // change url for sorting if segments are used
    if($input->urlSegmentsStr){
        $currentUrl = $page->url.$input->urlSegmentsStr."/";
    }else {
        $currentUrl = $page->url;
    }

So the url now displays: /pagename/subpage/segment1/segment2/page2/?sort=name

Pagination seems to work, keeping field and sort.

Except when sorting again, on page2, any new sort will return back to page1 (not keeping the current page number 2).

EDIT ----

Actually come to think of it: why would I need to stay on that page after a sort (in any order)? After all, I request a new sort and want to see whats the first result, right?!

So I will close this topic... sorry!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...