Search code examples
phpgetcontao

Check if URl get parameter exists


my CMS generates some parameter like this: domain.com/group?page_n531=2

The usual code is:

if (isset($_GET["id"]))
{

}

But my CMS changes the 'id' for every page, I just want to check, if a parameter exist, I dont need the 'id'. Can you guys help me with that?

Thanks.


Solution

  • The numeric part of the parameter is the id of the news module.

    It is generated like: $id = 'page_n' . $this->id;

    so your code (assuming you are in mod_newslist.html5 template) should read:

    if (isset($_GET['page_n' . $this->id]))
    {
        // Yeah we are on some page in the pagination.
    }
    

    If you should happen to be in template news_full.html5 or any other of the partial templates, you are out of luck, when hoping for a generic approach, as the id of the calling module is not available within there.

    In this cases you will have to create different news_*.html5 templates for each list module and assign it as news template to said module. Within there you can hard code the module id then.