We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30734
    • 44 Posts
    Hello everyone,
    I have a question regarding managing documents with Migxdb. Currently my client has around 10 pdf documents that get updated on a regular basis. Each of these documents gets linked to in the main navigation, setup with wayfinder, and are linked to in page content. Currently, I have hidden static resources for each document which is linked to in text and are also linked to using a weblink which is in the resource tree for the navigation.

    The problem: The client doesn't like this solution. They really like the ease of use with the features I have added with migxdb. Is there a way to make a sort of pdf manager with migxdb? I need for them to be able to update the pdf and both the nav link and the content links to be updated when the document is replaced.

    Thanks!

    This question has been answered by Bruno17. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      If everything, what you need is, let to edit his existing PDF - Resources (pagetitle and content=filename) in a MIGXdb - CMP this very simple configuration can do it

      Don't forget to change the where under MIDXdb - settings to the parent where your pdf-resources are

      {"parent":"159"}


      to add new pdf-resources they will still need todo that within the resource-tree.
      Of course this could be done with the CMP, too, with a little more efforts.

      here is the configuration for that CMP.

      {
        "formtabs":[
          {
            "MIGX_id":83,
            "caption":"PDF",
            "print_before_tabs":"0",
            "fields":[
              {
                "MIGX_id":378,
                "field":"pagetitle",
                "caption":"Pagetitle",
                "description":"",
                "description_is_code":"0",
                "inputTV":"",
                "inputTVtype":"",
                "validation":"",
                "configs":"",
                "restrictive_condition":"",
                "display":"",
                "sourceFrom":"config",
                "sources":"",
                "inputOptionValues":"",
                "default":"",
                "useDefaultIfEmpty":"0",
                "pos":1
              },
              {
                "MIGX_id":379,
                "field":"content",
                "caption":"File",
                "description":"",
                "description_is_code":"0",
                "inputTV":"",
                "inputTVtype":"file",
                "validation":"",
                "configs":"",
                "restrictive_condition":"",
                "display":"",
                "sourceFrom":"config",
                "sources":"",
                "inputOptionValues":"",
                "default":"",
                "useDefaultIfEmpty":"0",
                "pos":2
              }
            ],
            "pos":1
          }
        ],
        "contextmenus":"update",
        "actionbuttons":"",
        "columnbuttons":"",
        "filters":"",
        "extended":{
          "migx_add":"Add PDF",
          "disable_add_item":"",
          "add_items_directly":"",
          "formcaption":"",
          "update_win_title":"",
          "win_id":"migxpdfresources",
          "maxRecords":"",
          "addNewItemAt":"bottom",
          "multiple_formtabs":"",
          "multiple_formtabs_label":"",
          "multiple_formtabs_field":"",
          "multiple_formtabs_optionstext":"",
          "multiple_formtabs_optionsvalue":"",
          "actionbuttonsperrow":4,
          "winbuttonslist":"",
          "extrahandlers":"",
          "filtersperrow":4,
          "packageName":"",
          "classname":"modResource",
          "task":"",
          "getlistsort":"",
          "getlistsortdir":"",
          "sortconfig":"",
          "gridpagesize":"",
          "use_custom_prefix":"0",
          "prefix":"",
          "grid":"",
          "gridload_mode":2,
          "check_resid":"0",
          "check_resid_TV":"",
          "join_alias":"",
          "has_jointable":"no",
          "getlistwhere":{
            "parent":159
          },
          "joins":"",
          "cmpmaincaption":"PDF Manager",
          "cmptabcaption":"PDFs",
          "cmptabdescription":"Manage PDFs here",
          "cmptabcontroller":"",
          "winbuttons":"",
          "onsubmitsuccess":"",
          "submitparams":""
        },
        "columns":[
          {
            "MIGX_id":1,
            "header":"ID",
            "dataIndex":"id",
            "width":10,
            "sortable":"false",
            "show_in_grid":1,
            "renderer":"",
            "clickaction":"",
            "selectorconfig":"",
            "renderchunktpl":"",
            "renderoptions":"",
            "editor":""
          },
          {
            "MIGX_id":2,
            "header":"Pagetitle",
            "dataIndex":"pagetitle",
            "width":30,
            "sortable":"false",
            "show_in_grid":1,
            "renderer":"",
            "clickaction":"",
            "selectorconfig":"",
            "renderchunktpl":"",
            "renderoptions":"",
            "editor":""
          },
          {
            "MIGX_id":3,
            "header":"File",
            "dataIndex":"content",
            "width":30,
            "sortable":"false",
            "show_in_grid":1,
            "renderer":"",
            "clickaction":"",
            "selectorconfig":"",
            "renderchunktpl":"",
            "renderoptions":"",
            "editor":""
          }
        ]
      }
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 30734
        • 44 Posts
        Bruno
        Thank you very much! This was very helpful. You mentioned that with a little more effort I could set it up so that the document resource could be added from the CMP, could you point me to a tutorial or another post showing how to do this? I know the client will want it setup that way.

        Again, thank you very much for you help on this!
          • 30734
          • 44 Posts
          One more odd thing that came up, When I add a media source so that the client only accesses the documents folder I created it doesnt populate any files. In the Files tab on the left however all the documents show up no problem.

          I have tested this with other media sources I am using with other migxdb setups and those do not work either. Any insights as to why it might be doing this and how to fix it.
            • 30734
            • 44 Posts
            Alrighty
            I was hoping to figure out this on my own so I stopped myself from posting until now. What Bruno suggested did work, however I needed to add a media source to my documents folder so the client doesnt accidentally upload file to the root or httpdocs folder instead of the documents folder (which has happened many times).

            I added the media source and connected it to the File field and while nothing showed up initially when I clicked the files button on the left everything showed up. I thought everything was working at this point until I realized that when I added the media source it removed the "documents/" from the file path which is causing it to look in the wrong place for the file. Is there anything I can do to fix this?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Yes. Well, sort of.

              Static resources do not actually use Media Sources at all; they were developed before Media Sources were available and never updated to use them (I've been complaining about this ever since Revo 2.2.4). While you can use a Media Source to upload or select a file, that is a function of the File Browser itself. The static resource does not record which Media Source you selected, nor the path of the Media Source, just the part of the file's path after the Media Source's path.

              There are two ways to work around this. One is to put the full path in the Media Source, both in the "path" and in the "url" field, and set them both to be not relative. This is useless to the URL field since it's from the server file system root and not the web root, but it does cause the full path to be saved by the static resource - except for the leading /. This has to be added by the user, or in a plugin. This has the disadvantage of not changing if the path in the Media Source is changed. It will NOT work for Media Sources using other drivers, such as the Amazon S3 driver. The files must be on the same server as the MODX installation, although the Media Source can point to a directory outside of the web root. This is because MODX takes binary Static Resources out of the normal request handler processing, gives them different HTTP headers, and streams them to the browser.

              The way I prefer uses a chunk with the same path as the Media Source path. This chunk is prepended to the path saved by the static resource as a regular MODX chunk tag, again either by the user or by a plugin. If the path in the Media Source is changed, change the chunk as well.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org