Permalinks field always required

4 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 10, 2019   (RSS)

By daniel - June 7, 2019

Hey Greg,

Unfortunately, the Permalinks plugin requires "permalink" fields to be filled when saving records through the admin. For your use case, is the issue having to enter the permalink for entries that don't need one, or do you specifically want some records in that table to be inaccessible via permalink? Depending on your desired result, there may be some room to work around the issue without having to modify the plugin itself.

Thanks,

Daniel
Technical Lead
interactivetools.com

By gversion - June 7, 2019

Hi Daniel,

Thanks for the reply.

I use the permalink to display all listings for a user (e.g. www.mywebsite.com/username) however I would like to only require a permalink if the user is on a subscription (cmsb_subscription). If the user does not have a subscription selected then the permalink should not be required.

If the above is too tricky to achieve without modifying the plugin then I would really appreciate it if you could offer me the solutions you can think of and then I will try to work with them.

One solution could be to just set the permalink for all users that register though I am not sure how to do this.

Thanks again,

Greg

By daniel - June 10, 2019

Hi Greg,

One feature that the Permalinks plugin offers is automatic permalink generation, which may be helpful in your situation. This can be set up using the configuration options at the top of permalinks.php. If you want to auto-populate using the "username" field, it would look something like this:

$GLOBALS['PERMALINKS']['autopopulate']            = true;
$GLOBALS['PERMALINKS']['autopopulate_fromFields'] = array('username'); 

The result of this is when the permalink field is left blank when saving a record, the plugin will look for a field called "username" - if it exists that value will be used to create the permalink. Note that if you're already using this feature for other tables, you'll want to add the 'username' field to the array rather than replace existing items.

Further, to restrict non-subscribed members from having a permalink, you can check for the "cmsb_subscription" field on the display page and display a warning/error instead of the listings if they are not subscribed. In this way, any user may have a permalink but only subscribed members can use it.

Let me know if you have any luck with this approach, or if you have any more questions!

Thanks,

Daniel
Technical Lead
interactivetools.com