Results 1 to 3 of 3

Thread: Cleaning Query Strings in Urls

  1. #1
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Cleaning Query Strings in Urls

    Hey, if I have a module that lists a bunch of items, but also has a set of fields to filter the listing, when a user chooses an option for one of the filters, the resulting Url looks like this...

    /some-page/?a=&b=&c=&d=&e=something&f=

    What's the best way to clean out the empty parameters in that? Is there a built-in Contao method for doing this?

    Right now I'm looping through all the GET variables, removing the empty ones manually and then redirecting at the end. But I was just curious if there's an easier/more efficient way.
    Brian

  2. #2
    User
    Join Date
    06-19-09.
    Posts
    328

    Default Re: Cleaning Query Strings in Urls

    I think it is as simple as
    Code:
    $clean_get = array_filter($_GET);
    then you can re-create the url by using the "Controller::generateFrontendUrl" method
    Consulenza Contao CMS https://www.intco.it

  3. #3
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: Cleaning Query Strings in Urls

    Awesome, thanks. Simple indeed.
    Brian

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •