Change default Records Per Page in a Multi Record section
17 posts by 4 authors in: Forums > CMS Builder
Last Post: August 9, 2013 (RSS)
By Dave - March 5, 2013
Hi Jerry,
Backup your /data/schema/ first and then try this (also attached):
<?php
/*
Plugin Name: Per Page Changer
Description: Change default "Per Page" values on all schemas
Version: 1.00
Requires at least: 2.51
*/
### UPDATE THESE VALUES
$GLOBALS['PERPAGECHANGER_NEWVALUE'] = 1000; //
// DON'T UPDATE ANYTHING BELOW THIS LINE
// plugin menu - add link
pluginAction_addHandlerAndLink(t('Update Sections'), 'perPageChanger', 'admins');
//
function perPageChanger() {
foreach (getSchemaTables() as $tableName) {
$schema = loadSchema($tableName);
$schema['_perPageDefault'] = $GLOBALS['PERPAGECHANGER_NEWVALUE'];
saveSchema($tableName, $schema);
alert("Updated '$tableName' to have a per page default value of {$GLOBALS['PERPAGECHANGER_NEWVALUE']}<br/>\n");
}
}
?>
Let me know how it goes. Cheers!
interactivetools.com
By gkornbluth - March 7, 2013
Thank You Dave,
I think it will be come in very handy
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
By Codee - May 30, 2013
Hi Dave,
This plugin's feature is not readily reversible. In other words, if it's deactivated the system does not revert the per page field back to default. In other words, used once and all the per page defaults are automatically/perpetually set to 1000.
By Dave - May 30, 2013
Hi Terry,
Yea, that's right. It basically automates the task of going in and changing them all manually.
If you wanted to change them all back to 25 (the default) you could just change this line and run it again:
$GLOBALS['PERPAGECHANGER_NEWVALUE'] = 25;
Hope that helps!
interactivetools.com
By Codee - August 8, 2013
If a client has CMSBVer2.17 and not able to upgrade to 2.51...how can we modify this plugin, or some other way to change the default #? In fact, my client is asking me to change hers to 2000 ! ;-)
By gregThomas - August 9, 2013
Hi equinox,
If you try modifying the plugin to allow version 2.17, it will probably still work. We used 2.51 as the minimum version as that is the version we tested the plugin on.
<?php
/*
Plugin Name: Per Page Changer
Description: Change default "Per Page" values on all schemas
Version: 1.00
Requires at least: 2.16
*/
### UPDATE THESE VALUES
$GLOBALS['PERPAGECHANGER_NEWVALUE'] = 1000; //
// DON'T UPDATE ANYTHING BELOW THIS LINE
// plugin menu - add link
pluginAction_addHandlerAndLink(t('Update Sections'), 'perPageChanger', 'admins');
//
function perPageChanger() {
foreach (getSchemaTables() as $tableName) {
$schema = loadSchema($tableName);
$schema['_perPageDefault'] = $GLOBALS['PERPAGECHANGER_NEWVALUE'];
saveSchema($tableName, $schema);
alert("Updated '$tableName' to have a per page default value of {$GLOBALS['PERPAGECHANGER_NEWVALUE']}<br/>\n");
}
}
?>
Let me know if this doesn't work.
Cheers
Greg
PHP Programmer - interactivetools.com