We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19328
    • 433 Posts
    I'm using the childresources migxdb config to list galleries that are made with Moregallery. It's working, but when creating a new resource (a gallery) I need to set the class_key to mgResource instead of modDocument. I thought I could do this by creating a hidden field in the Formtabs called 'class_key' and with default value 'mgResource'. I do this for a couple of other thing like template and properties and show_in_tree, and those work, but the class_key doesn't. It is still 'modDocument'. Am I doing something wrong? Thanks for any help!
      • 19328
      • 433 Posts
      Still trying to figure this out. I did some testing: I made the class_key field not hidden and I found out a couple of things:

      1) with the class_key not hidden, the value 'modDocument' is already filled in when I add a new resource, despite my default value of 'mgResource'.

      2) when I try to save the resource nothing happens, and there is an error in my dev console that has to do with the post to assets/components/migx/connector.php (500 internal server error). This happens when I change the value of class_key to 'mgResource' but also when I just leave it to 'modDocument'. So by making the class_key field not hidden, I can't save a new resource anymore.

      I also did some digging around in the migx files, and found that in core/components/migx/processors/mgr/migxdb/fields.php a few lines concerning the class_key where commented out. I put those back and tried to save a resource again, and what do you think.. it worked!

      But I'm sure those lines where commented out because of a good reason.. So I'm hoping Bruno or someone else who knows why can tell me if it's safe to use them?

      The lines that I added to core/components/migx/processors/mgr/migxdb/fields.php are:

      $resourceClass= isset ($_REQUEST['class_key']) ? $_REQUEST['class_key'] : 'modDocument';
      $resourceClass = $modx->sanitizeString($resourceClass);
      $resourceClass = str_replace(array('../','..','/','\\'),'',$resourceClass);
      $resourceDir= strtolower(substr($resourceClass, 3));


      Thanks!
      - Michèlle
        • 19328
        • 433 Posts
        Hmm, just found out that it doesn't work anymore if I make the field hidden again and set a default value 'mgResource'. It won't save. It only works if I manually type 'mgResource' in a not hidden 'class_key' field. Which is not something I can ask my clients to do... What could be the problem? Hope someone can help me out here!

        EDIT

        I think I really found the solution now ;-)

        I opened all the files in <mymigxpackage>/processors/mgr/default

        and I changed 'modResource' to 'mgResource'. I realized that the gallery is another class which extends modResource, so I hoped that changing the class would add the correct class_key automatically and it seems to work. [ed. note: michelle84 last edited this post 12 years, 8 months ago.]