Best Method for Detecting Query Strings

2 posts by 2 authors in: Forums > CMS Builder
Last Post: November 19, 2014   (RSS)

Hello, All -

Ever since I started using Permalinks I've run into an issue with Query Strings. The plugin makes it possible to load a page using either of two URLs. For example:

1) www.mywebby.com/index.php?page=12

or

2) www.mywebby.com/gallery

It doesn't matter which URL you use, you still end up on the same page. Fine.

My problem (and confusion) comes when it is necessary to add a query string. Using the example above, let's say I now want to load picture number 4. I would append the URL with something like this:

pic=4

The question is, how do I join pic=4 to the URL examples given above?

In example 1 a query string already exists so I need to add &pic=4. In the second example there is no query string so I need to create one using: ?pic=4.

Is there a common method or formula for detecting whether or not a query string exists and thus which joining method to use?

Thanks,

Perch