We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23018
    • 353 Posts
    I want to create a new resource using a link but I have problems setting the right paramters:

    querystring = "&parent=33&template=35&class_key=modStaticResource&content_dispo=inline&content_type=pdf";
    MODx.loadPage(MODx.action['resource/update'], querystring);
    


    parent,template and class_key work like intended, but content_dispo and content_type don't.

    Whatever I set, it has no effect.

    Is it possible, that these properties cannot be set?

    Regards,

    pepebe
      Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
      • 23018
      • 353 Posts
      I've opened an issue about this topic.

      https://github.com/modxcms/revolution/issues/11340

      As far as I can se both settings are not among the settings that can be preconfigured for a new resources by adding them to the resource/create link.
        Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe
        • 4172
        • 5,888 Posts
        I think you can set these resource-fields at onDocFormRender

          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 23018
          • 353 Posts
          @Bruno. Sorry for the late reply. Yes, this seems to be a proper way to do that.

          I tried to change field values onDonFormRender, but there is something going on in the background that prevents me from setting it with js.

          Example:

          MODx.on('ready',function() {
          var value = 8; // =pdf
          
          var path = 1; /* or 2... */
          
          if(path = 1){
             var field = Ext.getCmp('modx-resource-content-type');
             field.setValue(value);
          }
          
          else if(path = 2){
             var field = document.getElementsByName('content_type')[0];
             field.value = value
          }
          
          console.log('value =' + field.value); // Result: 8
          });
          


          Console.log returns the expected result, but there is neither a visible change to the content_type combobox nor to the hidden content_type input field. At least the later one should be changed, because this is where the displayed value comes from.

          I do this all the time for datefields, select tvs or normal text fields like link_attributes. Never had a problem changing values.

          If I open the console and manually type:

          Ext.getCmp('modx-resource-content-type').setValue(8)


          Both the combobox as well as the hidden input field change to "PDF" and "8".

          Its monday, so its not unusual that my gremlins are eager to mess up with my coding, but I don't have a clue whats going on here. If anyone can shed a light, I would be very happy.

          Cheers,

          pepebe [ed. note: pepebe last edited this post 12 years, 4 months ago.]
            Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe