We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29703
    • 217 Posts
    Hello smiley

    I’ve decided to stick to room 101 as my questions seem recurringly basic in comparison to other peoples.

    I have been trying to get a decent file download portal system working but can’t really get close. People have recommended FileDownload and some similar things, but I can’t really get my head round them.

    This is how I visualise what I want:

    I want a chunk that contains variables that can be modified when calling the chunk. So I have my nice little chunk {{downloadbox}} with a load of empty divs in. I then want to be able to able to add content to these empty divs using variables when calling the chunk.

    I have a feeling I am going completely the wrong way about this, but can anyone help? huh
      • 7231
      • 4,205 Posts
      I want a chunk that contains variables that can be modified when calling the chunk. So I have my nice little chunk {{downloadbox}} with a load of empty divs in. I then want to be able to able to add content to these empty divs using variables when calling the chunk.

      A chunk cannot do any logic, it is just a place holder for html. I think that you would need to have a snippet and load the chunk dynamically. You could use the modx api functions to set placehoders and then load the chunk or you coudl do the layout within the snippet itslef and just return the layout.

      Here is an API example for setting placeholders and retrieving a chunk:
      http://wiki.modxcms.com/index.php/Creating_Snippets#Snippets_and_plugins_should_not_contain_presentation_layer_code

      To make a file download system use a document for each download file (add Template Variables to add custom fields like file url or thumbnail). Then you can present the files with Ditto and add a few search filtering tools (can be built with tvExplorer snippet) and meybe even add commenting (can be done with Jot snippet). FileDownload (snippet + plug-in) can be used to present the file for download.

      The modx site structure could look like this, where File Category # represent the different categories and File # represent the download documents:
      -Home
      -Downloads
      --File Category 1
      ---File 1
      ---File 2
      ---File 3
      --File Category 2
      ---File 4
      ---File 5 ...
      -Search
      -Contact
      - Etc..

      Instead of using categories you could also use tags and filter with Ditto.

      This is how I would do it, that does not mean that this is the best way to do it though, but it looks like it would work.
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 29703
        • 217 Posts
        Thanks for the reply!

        I think placeholders is the keyword I’ve been looking for really. I’m going to look into integrating what you’ve said.

        You mention creating a document for each download file. What if I have hundreds of download files? Isn’t that fairly impractical and longwinded?

        I want to really just be able to do something like this in the content editor:

        [!DownloadBox?&thumbnail=`images/thumbnail.jpg`&downloadurl='downloads/file.zip' &description='This is the description for the download'!]


        and for it to call a snippet that prints the chunk, changing the selected parameters. Is this a riduculous way to approach this problem?
          • 7231
          • 4,205 Posts
          You mention creating a document for each download file. What if I have hundreds of download files? Isn’t that fairly impractical and longwinded?
          Yes it is a bit longwinded, but on the other hand it will give you manager access to the download files and related information as well as allowing you to use modx snippets like Ditto to display the file info. This is a headache at start-up (having to input all the data for hundreds of docs is time consuming and tedious) but one loaded it will be a breeze to manage the file. However, you can very well use a custom method and keep the overhead down (by not parsing or caching the file info since it will come from direct query).

          I think that there may be an import snippets available that can load docs from a CSV file.
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]