We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38209
    • 26 Posts
    Yes, looks nice huh smiley sometimes it's easier to do things another way and to start asking how you can achieve what you want instead of how you are going to achieve it with your current code . laugh
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Why don't you do the matching in your mgr/subscribers/getList processor?

      You didn't post the actual code for it, but it seems that you are already fetching the "extended" field (which is an array) so you have the data for it available. It's $user->Profile->get('extended'). Then do whatever matching you need to do against that data.. I'm not sure what your data model is for storing it.. if (test2 == ID of checkbox)?

      To save an extended field, just get the current one, and merge your extended in it, and set it again.

      $extended = $user->Profile->get('extended');
      $newExtended = array(
        'foo'  => 'bar',
      );
      $extended = array_merge($extended, $newExtended);
      $user->Profile->set('extended', $extended);
      $user->Profile->save();
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 10378
        • 375 Posts
        Quote from: markh at Nov 26, 2012, 09:20 AM
        Why don't you do the matching in your mgr/subscribers/getList processor?

        You didn't post the actual code for it, but it seems that you are already fetching the "extended" field (which is an array) so you have the data for it available. It's $user->Profile->get('extended'). Then do whatever matching you need to do against that data.. I'm not sure what your data model is for storing it.. if (test2 == ID of checkbox)?

        Hi Mark thanks for jumping in,

        doing the matching in the mgr/subscribers/getList processor was my initial intention (you can see this a few post above).

        I have the data available in GoodNews.window.UpdateSubscriber but I absolutely don't know how to pass this value to the catCheckboxGroup function (line 34 of the source below) which handles the JsonStore. I'm a JavaScript noob - you must know. smiley
        How can I access the value of the field "extended" in GoodNews.window.UpdateSubscriber (see source below)?

        Here is the source (a part of it) once again:

        ...
        
        GoodNews.window.UpdateSubscriber = function(config) {
            config = config || {};
            
            console.log(this);
        
            Ext.applyIf(config,{
                title: _('goodnews.subscriber_update')
                ,url: GoodNews.config.connectorUrl
                ,baseParams: {
                    action: 'mgr/subscribers/update'
                }
                ,fields: [{
                    xtype: 'hidden'
                    ,name: 'id'
                },{
                    xtype: 'displayfield'
                    ,fieldLabel: 'extended field'
                    ,name: 'extended'
                    ,readOnly: true
                },{
                    xtype: 'displayfield'
                    ,fieldLabel: _('goodnews.subscriber_username')
                    ,name: 'username'
                    ,readOnly: true
                },{
                    id: 'cat-ext-checkboxgroup'
                    ,fieldLabel: _('goodnews.subscriber_categories')
                    ,name: 'newslettercategories'
                    ,listeners: {
                        'render': {
                            fn: function() {
                                catCheckboxGroup('cat-ext-checkboxgroup','newslettercategories');
                            }
                        }
                    }
        
                }]
            });
            GoodNews.window.UpdateSubscriber.superclass.constructor.call(this,config);     
        };
        Ext.extend(GoodNews.window.UpdateSubscriber,MODx.Window);
        Ext.reg('goodnews-window-subscriber-update',GoodNews.window.UpdateSubscriber);
        
        ...
        

          Freelancer @bitego http://www.bitego.com
          ---
          GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
          More infos here: http://www.bitego.com/extras/goodnews/
          • 10378
          • 375 Posts
          Quote from: scherpontwikkeling at Nov 26, 2012, 06:47 AM
          Please use this myscript.js.txt ;-)

          Hello,

          ok - I tried to implement your solution but the new fields never get displayed in the MODx user edit form!?
          Created a new plugin - pasted the php source you sent me. Attached the events you told me (OnUserFormPrerender, OnUserFormSave). Created a new js file in /assets/ pasted the js code you sent me - cleared the cache - but nothing happens.

          By the way - I forgot - I can't really use your solution as I then loose the ability to limit access to a specific group of subscribers (for admins). MODx currently only allows to completely allow or deny access to the user table (as far as I know). Therefore I have to do this it with a CMP grid.

          But I think the hint you gave me is of high value for all other MODx developers - I never saw anything like this in documentation or forums the two years I'm at the MODx train! Great!
            Freelancer @bitego http://www.bitego.com
            ---
            GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
            More infos here: http://www.bitego.com/extras/goodnews/