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!

Dave Edis - Senior Developer
interactivetools.com
Attachments:

perpagechanger.php 1K

By gkornbluth - March 7, 2013

Thank You Dave,

I think it will be come in very handy

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







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 Codee - May 30, 2013

Okay. Cool. Thanks. Have a great week!

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 ! ;-)

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

Greg Thomas







PHP Programmer - interactivetools.com