Force a field to lower case

11 posts by 4 authors in: Forums > CMS Builder
Last Post: March 24, 2018   (RSS)

By garyhoffmann - March 20, 2018

Is there a way to force a field to lower case?  For example, I have a field called seo_page_name.  (Yes, I've had this long before permalink plug-in existed.)  Sometimes users are not as diligent about making sure they use lower case in these fields.  I would like to force the field to lower case.  I know I can restrict them to using lower case letters, numbers and a dash only, but I would like to take whatever they type into this field and force it to lower case.  Is that possible?

Thanks,

Gary.

By Deborah - March 20, 2018

Gary, I have this in my snippets library that might be what you're looking for:

<?php echo strtolower($listingsRecord['property_type:label']) ?>

(ref: http://php.net/manual/en/function.strtolower.php)

~ Deborah

By mizrahi - March 20, 2018

I believe they want this to happen in the CMS as the info is being entered, or after its saved. 

By garyhoffmann - March 21, 2018 - edited: March 21, 2018

Correct (want this to happen in CMS).  There's another option I could do.  You see, I use this as a permalink.

Deborah - thank you for your response, but that's too late in the process.

What I want to ensure is that http://www.somesite.com/some-page-name will be found in the database.  If the SEO page name (or permalink) is Some-Page-Name, it will not be found.  I need to ensure it will be.  Maybe there's another way around it when I read from the database, such as doing a case insensitive search for the value. 

The other concern that I have is that each page MUST have a unique value and I'm afraid that Some-Page-Name and some-page-name are not identical and will not trigger the "unique" flag.  If I convert the value to lowercase BEFORE this unique comparison is done, they will be the same.

I was looking around the site to see if there was some documentation on writing add-ons.  I could use this approach if nothing else, but I don't know all the hook names for addAction.

I may just go this route if I can figure out how/where to use it.  Does anyone know if there are docs on creation of add-ons?

Thanks in advance.

Gary.

By mizrahi - March 21, 2018

Is there not a way for you to transition to the permalinks plugin for this? It seems like it would address these issues quite well, and provide it's additional benefits? How extensive of a data set are you talking about?

By garyhoffmann - March 21, 2018

Hi - we have about 150-200 sites right now using CMSB, so I would like to put my add-on in place as we have a reason to touch a site.  The permalink add-on is rather costly for doing almost the exact same thing I already do.  I just never thought about the case issue before yesterday when a customer couldn't get their links to work correctly...then we figured out why.

Gary.

By garyhoffmann - March 21, 2018

I opted to buy the permalink add-on - hopefully that will make life a bit easier - I like the history capability in it - something I have not done.  That's worth the cost of it right there.

I'll see how this goes for me.

Gary

By mizrahi - March 21, 2018

Good luck. It took me a few sites to get the hang of it, but I really love it now. 

By Dave - March 23, 2018

Hi Gary, 

What's the exact issue you are trying to solve? CMS Builders built-in unique field checks are case insensitive.  And if you have some custom MySQL code you can convert to lowercase with the MySQL LOWER() function.

Dave Edis - Senior Developer
interactivetools.com