Permalinks field always required

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

By gversion - June 5, 2019

Hello,

I am using the permalinks plugin and there is a "permalink" field on my CMSB accounts table.

The problem is that this field is always required even if a user should not have a permalink.

I have not ticked the "required" checkbox (user may not leave field blank) in the section editor settings.

Can someone please assist? I would like to stop having to enter a permalink for a user when I need to make an update to their account details.

Thank you,

Greg

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 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