Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Inline Overide of list_max_entries_per_page

  1. #1
    tj@estreet.com is offline Sugar Community Member
    Join Date
    Feb 2006
    Posts
    163

    Default Inline Overide of list_max_entries_per_page

    Has anyone tried (better still succeeded in) creating an in-line override to adjust "list_max_entries_per_page" in config.php ON THE FLY?
    If not, any thoughts on how to accomplish???

  2. #2
    tj@estreet.com is offline Sugar Community Member
    Join Date
    Feb 2006
    Posts
    163

    Default Re: Inline Overide of list_max_entries_per_page

    Surely somebody has done this???

  3. #3
    tj@estreet.com is offline Sugar Community Member
    Join Date
    Feb 2006
    Posts
    163

    Default Re: Inline Overide of list_max_entries_per_page

    I can’t believe no one has done this but... here’s what I’ve come up with -- so far.

    Adding this to config.php
    PHP Code:
    $display_selection_count 20
    if(isset(
    $_GET['user_display_selection_count']) && preg_replace("/\D/","",$_GET['user_display_selection_count'])!="") { 
        
    $display_selection_count $_GET['user_display_selection_count']; 

    ... and replacing:
    PHP Code:
    'list_max_entries_per_page' => 20
    ...with
    PHP Code:
    'list_max_entries_per_page' => $display_selection_count
    Then altering contacts.html as follows:
    HTML Code:
    <!-- BEGIN: main -->
    <table cellpadding="0" cellspacing="0" width="100%" border="0" class="listView">
    <tr><td colspan="10" align="right">Show 
    <a href="index.php?module=Contacts&action=index&user_display_selection_count=10&module=Contacts&action=index">[10]</a>
    <a href="index.php?module=Contacts&action=index&user_display_selection_count=20&module=Contacts&action=index">[20]</a>
    <a href="index.php?module=Contacts&action=index&user_display_selection_count=50&module=Contacts&action=index">[50]</a>
    <a href="index.php?module=Contacts&action=index&user_display_selection_count=100&module=Contacts&action=index">[100]</a>
    <a href="index.php?module=Contacts&action=index&user_display_selection_count=200&module=Contacts&action=index">[200]</a>
    </td></tr>
    <!-- BEGIN: list_nav_row -->
    I am able to change list_max_entries_per_page value on the fly, but only from Contacts/ListView.html.

    What I can’t figure out, is how to set it up so that it will work for all ListViews in the header/footer
    ( |<<Start <Previous (count) Next> End>>| Show [10] [20] [50] [100] [200] )
    ...for ALL lists INCLUDING sub-panels???
    This would be especially useful in the creation of Target Lists for Campaigns. No?

    Can any of you hard-core programmer types (Ajay, Chris, Ken???) offer any insight.
    Please Advise

  4. #4
    WayneSugar's Avatar
    WayneSugar is offline Sugar Community Member
    Join Date
    Oct 2005
    Posts
    155

    Default Re: Inline Overide of list_max_entries_per_page

    simply override by using
    $GLOBALS['sugar_config']['list_max_entries_per_page'] = $num;
    for subpanels it is a different parameter:
    $GLOBALS['sugar_config']['list_max_entries_per_subpanel'] = $num;

    this is before any of the core listview code is called.
    Wayne Pan
    Software Eng.

  5. #5
    tj@estreet.com is offline Sugar Community Member
    Join Date
    Feb 2006
    Posts
    163

    Default Re: Inline Overide of list_max_entries_per_page

    Thanks Wayne,

    Wish I understood that. Could you clarify a bit for me please? Editing which files specifically?

  6. #6
    tj@estreet.com is offline Sugar Community Member
    Join Date
    Feb 2006
    Posts
    163

    Default Re: Inline Overide of list_max_entries_per_page

    I think Wayne has left the building. Anybody else have any idea what he meant by:
    Quote Originally Posted by WayneSugar
    simply override by using
    $GLOBALS['sugar_config']['list_max_entries_per_page'] = $num;
    for subpanels it is a different parameter:
    $GLOBALS['sugar_config']['list_max_entries_per_subpanel'] = $num;

    this is before any of the core listview code is called.
    Last edited by tj@estreet.com; 2006-09-26 at 05:55 PM.

  7. #7
    tj@estreet.com is offline Sugar Community Member
    Join Date
    Feb 2006
    Posts
    163

    Default Re: Inline Overide of list_max_entries_per_page

    Come on folks. Somebody jump on this please.

  8. #8
    cywolf's Avatar
    cywolf is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    Toronto, Canada
    Posts
    223

    Default Re: Inline Overide of list_max_entries_per_page

    Putting the code samples together, you get something like this:

    PHP Code:
    if(! empty($_REQUEST['user_display_selection_count']) && is_numeric($_REQUEST['user_display_selection_count'])) { 
        
    $GLOBALS['sugar_config']['list_max_entries_per_page'] = $_REQUEST['user_display_selection_count'];

    I'm not too familiar with 4.5 architecture yet, but under 4.2 you could add that to the processListViewTwo method of the ListView class (include/ListView/ListView.php). Alternatively, and maybe easier, you could just add this to index.php, somewhere after the inclusion of config.php. That would affect every single page.
    Andrew Whitehead
    The Long Reach Corporation
    http://infoathand.com

  9. #9
    stevec is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,100

    Default Re: Inline Overide of list_max_entries_per_page

    I believe Wayne means that to add the reassignment of $GLOBALS['sugar_config']['list_max_entries_per_page'] should be made in the ListView.php file for the appropriate module neaer the beginning of the file.

    Similarly, put the new value for $GLOBALS['sugar_config']['list_max_entries_per_subpanel'] near the begining of the parent module's DetailView.php file.

    What would be a useful trick is to be able to set this override individually for users.

  10. #10
    tj@estreet.com is offline Sugar Community Member
    Join Date
    Feb 2006
    Posts
    163

    Default Re: Inline Overide of list_max_entries_per_page

    Thanks Andrew and Steve,

    When I implemented the code originally offered above (Contacts/ListView only), I was surpised to find it functioned on a per user basis, as it was my intent that it would be per view.

    Plugging in only one option purely as a test:
    <a href="index.php?module=Contacts&action=index&user_ display_selection_count=10&module=Contacts&action= index">[10]</a>
    I was surpised -- after a successful test -- when I returned later to contacts/list view to find it stuck returning only ten records in the list. I logged out (user Admin) and back in again and still only 10 results in list. I logged out, and back in as user TJ, and sure enough, I was back to the default of 20. Hmmm, I thought to myself. Not what I intended, but not a bad thing. In fact... I think I like it!

    As user TJ I clicked my new "display_selection_count" link, and returned only10 results, Logged out, back in as Admin and sure enough, only 10 results. Gee, I had better add the remaining options [20][50][100][200] so I'm not stuck viewing only 10 results in my contacts list, then I'll present this in the Sugar Forums and see if we can't get it working for ALL lists.

    That was days ago, many and various modifications to other modules, Admin/Repair database etc. waiting for some movement on this thread/topic, and now, as I prepare to respond to Steve that it works on a per user basis as is, much to my surprise I find it now only works on a per view basis. Go Figure!

    Still, in my vast ignorance, I have no clue how to apply this, in a sweeping fashion to all lists. Tried Andrew's suggestion, (adding the code he offered to index.php) but to no effect. Surely all approaches suggested require creation of a set of linkswhatever list is being viewed to set desired value ????

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •