CMSB v3.74 Released (Oct 31) - SmartArray & Maintenance Release
1 posts by 1 authors in: Forums > CMS Builder
Last Post: October 31 (RSS)
By Dave - October 31 - edited: October 31
Hi everyone,
Version 3.74 is now live! This maintenance release introduces SmartArray, a powerful new library we'll be using in future viewers/code generators. SmartArray makes it easier to work with arrays by adding chainable methods and automatic HTML encoding.
If you're comfortable with PHP code, here's how to try it now:
list($records, $metaData) = getRecords(...);
$articles = new SmartArray($records); // create a SmartArray of records
SmartArray works just like an array but with additional features and automatic HTML encoding.
// Foreach over a SmartArray just like a regular array
// Values are automatically HTML encoded with SmartString
foreach ($articles as $article) {
echo "Title: {$article['title']}\n"; // use regular array syntax
echo "Title: $article->title\n"; // or cleaner object syntax (no curly braces needed)
}
Some of the available methods include:
// Accessing articles directly
$articles->first(); // get first record
$articles->last(); // get last record
$articles->nth(2); // get record by position (0-based, negative indexes allowed)
// When looping over records
foreach ($articles as $article) {
// Array Information
$article->isFirst(); // true if first record
$article->isLast(); // true if last record
$article->position(); // get position in list (starting at 1)
$article->isMultipleOf(3); // true if position divisible by 3 (for grids)
// Value Access
$article['key']; // array syntax access
$article->key; // object syntax access
$article->get('key'); // method syntax access
}
// Array Transformation
$articles->indexBy('num'); // index by a column, e.g., $articlesByNum
$articles->groupBy('author'); // group by a column (allows duplicates)
$articles->pluck('num'); // extract one column
$articles->pluck('num')->join(','); // join values with separator, e.g., "1,2,3,4"
$articles->map($callback); // transform each value with a callback function
$articles->chunk(3); // split into groups of N (for grid layouts)
// Converting back to regular array
$articles->toArray(); // convert back to regular PHP array
You can see more examples and the full documentation here:
https://github.com/interactivetools-com/SmartArray
The full changelog for this release is as follows:
*** October 31, 2024 - Version 3.74 (Maintenance Release)
SERVER REQUIREMENTS (Since Dec 2023): PHP 8.0+ and MySQL 5.7+ (or MariaDB 10.2+)
MINOR CHANGES
- Accounts Menu: Password fields now show ********* instead of a blank to indicate a password exists
- CMS .htaccess: Improved <FilesMatch> regex to proactively block more types of common sensitive files (*.bak, .env, etc)
- SSL Certificates: Updated CA Root Certificates in vendor/composer/ca-bundle/res/cacert.pem
- Added new SmartArray class for advanced array manipulation and formatting (beta)
BUG FIXES
- Upload Modify: Fixed "Requested key 'uploadNums' returned an unexpected array" error
- Website Membership: Fixed reset password error "_generatePasswordResetCode: User ### not found!" with non "accounts" tables
- Improved MySQL error handling and display messages for invalid columns
- Misc code and other minor improvements
You can download the latest version here: https://www.interactivetools.com/download/
Please feel free to ask any questions or post any feedback, questions, or bugs you find!
Thank you!
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com