Custom plugin to append article category to the permalink url

3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: April 6, 2016   (RSS)

By adventure - April 6, 2016

so I got the custom code to fire but now I am getting an error that says

Permalink can only contain these chars (a-z0-9/-.)!

This is the code:

// create custom permalink on first save of record
    if ($tableName == 'newsroom' && !$oldRecord) {
        echo $prefix . @$_REQUEST['category'] .'/'. @$_REQUEST['title'];
        
      $_REQUEST['permalink'] =  $prefix . @$_REQUEST['category'] ."/". @$_REQUEST['title'];
    }

in my testing I add the echo to see what was being passed in and it does not include any bad characters:

news/Video Advertising/Test Permalink Permalink can only contain these chars (a-z0-9/-.)

jill gerow

By Damon - April 6, 2016

Hi Jill,

The Permalinks plugin isn't designed to dynamically add categories to the permalink URLs.

In your test example, news/Video Advertising/Test Permalink Permalink, spaces is what is not allowed.  

The example plugin code Dave posted in the other thread was only a starting point which would need more code and testing to make work. There are several issues that have to be considered and resolved as Dave mentioned:

Note that overriding the permalinks field value will prevent the user from setting a custom permalink.  Another way to do it might be to write a plugin that used javascript to update the permalink field when the user selected/changed categories, but you'd need to think about what it should do when adding records vs editing, etc. 

Are you interested in getting a quote from our consulting department in getting this setup?

Let me know.

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/