Permalink Disappointment

Hello, All -

At first glance I thought the new Permalink plugin was the answer to my prayers. I bought it almost immediately.

On closer inspection, however, it does not seem able to handle complex query strings, eg:

www.mysite.com/index.php?cat=2&rec=4

This is a big disappointment - especially given that CMSB lends itself to the use of such big strings.

:0(

Perchpole

By Perchpole - March 3, 2013

Hi, Dave -

Hope the move is going well!

In response to your questions to my example (above), record 4 would always be associated with category 2. However, it would not be possible to load the category without the query string. This is important because the category determines the template (and other elements) used for  the record page.

:0)

Perch

By Dave - March 11, 2013

Hi Perch,

I'm going to see if I can add support for custom query strings for manually created permalinks.

However, about your example custom URLs: www.mysite.com/index.php?cat=2&rec=4

It might be easier if the viewer could automatically determine the category.  What if we just used this url: www.mysite.com/index.php?rec=4

And then we added a line of code to the top of the script to automatically load the category number from the record number?  Like this: 

$_REQUEST['cat'] = array_value( mysql_get('articles', @$_REQUEST['rec'] ), 'cat');

Note: That example code assumes your tablename is named 'articles', has a field named 'cat' and 'rec' refers to the 'num' field.

Or if you're already loading the article record you can set $_REQUEST['cat'] with that value.

Sometimes we "fake" request values to make lookups like this easier, or to make the urls look cleaner.  For example, I was working on a search form this morning and instead of the standard list of fields: 

<input type="text" name="title,tags,category,content_query" value="<?php echo htmlencode(@$_REQUEST['title,tags,category,content_query']); ?>" size="20"/>

I just used 'k' (for keyword): 

<input type="text" name="k" value="<?php echo htmlencode(@$_REQUEST['k']); ?>" size="20"/>

And then added this line to to the top of the script:

// fake query strings for nicer urls
if (@$_REQUEST['k']) { $_REQUEST['title,tags,category,content_query'] = $_REQUEST['k']; }

Let me know if you think there's a way we can get the category number dynamically instead of specifying it in the url.  If we can do that we can use the standard Permalinks functionality and it should all be pretty automatic.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com