CMSB 3 default field width

5 posts by 3 authors in: Forums > CMS Builder
Last Post: February 9, 2016   (RSS)

By kitsguru - February 5, 2016

I am wondering what the default field withs are in the section editor and if tnere is an easy way to set it for older sections. i am finding going through and manually adjusting each field for all the sections very tedious.

Suggestions?

Jeff Shields

By ross - February 9, 2016

Hi Jeff

Thanks for posting.

I know what you mean about having to changing the field length for each field individually.  

An advanced option you have is modifying the schema file directly.   If you are going to try this, make sure to have backups of both your database (you can use the backup tool in CMS Builder) and the schema file itself.  

When you open the schema file, look for this attribute:

'fieldWidth' => '',

There will be one of these for each text field in your section. Other field types won't have this attribute.

What you can do is a find and replace and change that to any of the following options:

Tiny
Small
Medium
Large
Full Width

Does that all make sense? I recommend asking any questions you have before trying anything.

Keep me up to date with how you are making out.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By ross - February 9, 2016

Hi Jeff

Sounds good Jeff.  Keep me up to date with how you are making out.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By Daryl - February 9, 2016

Hi Jeff,

I wrote a script that will convert field width pixels to CMSB 3.** size. 

If you're comfortable editing PHP files, you can try the following patch.

Search for the following code in "\cmsb\lib\menus\default\edit_functions.php"

$styleClassWidth = getBootstrapFieldWidthClass(@$fieldSchema['fieldWidth']);

and replace it with the following code:

  // get field width class
  $widthName      = @$fieldSchema['fieldWidth']; // eg: tiny, small, medium, large, full
  $isWidthNumeric = preg_match('/^\d+$/', $widthName);
  if ($isWidthNumeric) {  // convert legacy v2.xx field width pixels to named size (eg: 340 to small)
    $pixels = @$fieldSchema['fieldWidth'];
    if     (0 < $pixels   && $pixels <= 120)  { $widthName = "tiny"; }
    elseif (120 < $pixels && $pixels <= 340)  { $widthName = "small"; }
    elseif (340 < $pixels && $pixels <= 675)  { $widthName = "medium"; }
    elseif (675 < $pixels && $pixels <= 1010) { $widthName = "large"; }
    elseif (1010 < $pixels)                   { $widthName = "full"; }
  }
  $styleClassWidth = getBootstrapFieldWidthClass($widthName);   

Make sure to make a full backup first.

In the next CMSB release, we will add a support for legacy 2.** field width pixels by converting them to CMSB 3.** size natively.

Please let me know if you have any questions.

Thanks,

Daryl Maximo
PHP Programmer - interactivetools.com