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

Dave Edis - Senior Developer
interactivetools.com

By Codee - May 30, 2013

Okay. Cool. Thanks. Have a great week!

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