BC Media Downloads Exporter

I needed to migrate Media Downloads for a site I’m working on that has quite a few of these. Classifications were not used on the Site.

Here is how I handled it.

Files have to be downloaded from BC manually or taken from the documented file storage.
The storage location needs to be created in the Treepl CMS using File Manager and the Media Downloads need to be uploaded manually.

With no Media Downloads module in Treepl I created a Custom Module to hold them. I required 3 additional fields:

  • fileName type: media
  • fileSize type: number
  • fileType type: dropdown list

The dropdown list has the text version of the filetypes.

Once we move out of BC we don’t have access to their icons. I’ve used icons from Font Awesome.

I created a new page in BC & added the following code. The code has to be added via the Develop Tab or uploaded via FTP. The code is rearranged by BC when you save it from the Page Editor.

Migration Code in BC - edited in the Develop Tab:

{module_data resource="mediadownloads" version="v3" fields="id,name,literatureTypeId,description,displayFileName,size,downloadUrl,literatureType" skip="0" limit="500" order="id" collection="myData"}

{% assign treeplMediaFolder= "downloads" %}
{% assign treeplMediaPath = "/assets/" %}
{% assign treeplMediaPath = treeplMediaPath | append: treeplMediaFolder | append: "/" %}
{% capture downloadable %}?downloadable=1{% endcapture %}

<table border="1">
    <thead>
        <tr>
            <th>External ID</th>
            <th>Item Name</th>
            <th>Item Description</th>
            <th>Release Date</th>
            <th>Expiry Date</th>
            <th>Weight</th>
            <th>Template ID</th>
            <th>Enabled</th>
            <th>Classifications</th>
            <th>Item Tags</th>
            <th>Created By Member Id</th>
            <th>Author</th>
            <th>fileName</th>
            <th>fileSize</th>
            <th>fileType</th>
        </tr>
    </thead>
    <tbody>
        {% for item in myData.items-%}
            <tr>
                <td></td>
                <td>{{item.name}}</td>
                <td>{{item.description}}</td>
                <td>{{item.releaseDate | date: "%d-%M-yyyy"}}</td>
                <td>{{item.expiryDate | date: "%d-%M-yyyy"}}</td>
                <td>{% if item.weight != NULL %}
                        {{item.weight}}
                    {% else %}
                        0
                    {% endif %}</td>
                <td>0</td>
                <td>{{item.enabled}}</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td>{{item.displayFileName | prepend: treeplMediaPath }}{{downloadable}}</td>
                <td>{{item.size}}</td>
                {% case item.literatureTypeId %}
                    {% when 1 %}
                        {% assign litType = "Adobe Acrobat" %}
                    {% when 2 %}
                        {% assign litType = "Microsoft Word" %}
                    {% when 4 %}
                        {% assign litType = "Microsoft Excel" %}
                    {% when 5 %}
                        {% assign litType = "Microsoft Access" %}
                    {% when 6 %}
                        {% assign litType = "Archive File" %}
                    {% when 7 %}
                        {% assign litType = "Help File" %}
                    {% when 8 %}
                        {% assign litType = "Microsoft PowerPoint" %}
                    {% when 9 %}
                        {% assign litType = "Microsoft Project" %}
                    {% when 10 %}
                        {% assign litType = "Microsoft Visio" %}
                    {% when 11 %}
                        {% assign litType = "Text File" %}
                    {% when 12 %}
                        {% assign litType = "Word Perfect" %}
                    {% when 13 %}
                        {% assign litType = "Executable File" %}
                    {% when 14 %}
                        {% assign litType = "MP3" %}
                    {% when 16 %}
                        {% assign litType = "Windows Media" %}
                    {% when 17 %}
                        {% assign litType = "Real Audio" %}
                    {% when 18 %}
                        {% assign litType = "Adobe Flash" %}
                    {% when 19 %}
                        {% assign litType = "Other" %}
                    {% when 20 %}
                        {% assign litType = "MP3 (Streaming)" %}
                    {% when 21 %}
                        {% assign litType = "MP4 (Streaming)" %}
                    {% when 22 %}
                        {% assign litType = "M4A (Streaming)" %}
                    {% when 23 %}
                        {% assign litType = "MOV (Streaming)" %}
                    {% when 24 %}
                        {% assign litType = "M4V (Streaming)" %}
                     {% else %}
                        {% assign litType = "Unknown)" %}
                {% endcase %}
                <td>{{litType}}</td>
            </tr>
        {% endfor%}    
    </tbody>
</table>

The page presents a table that can be copied & pasted into Excel.

As described above I created a Custom Module to hold the Media Download data. I exported a Template & copied the data from the table into the appropriate columns into the Template and uploaded it into Treepl CMS.

In this case the List Layout for the Custom Module contained the following code:

{% case this['FileType'] %}
    {% when "Adobe Acrobat" %}  
          {% assign icon = "far fa-file-pdf" %}
    {% when "Microsoft Word" %}  
          {% assign icon = "far fa-file-word" %}
    {% when "Microsoft Excel" %}  
          {% assign icon = "far fa-file-excel" %}          
{% endcase %}          
<p class="literature-container"><i class="{{icon}}"></i> <span class="name"><a href="{{this['FileName']}}">{{this['Name']}}</a></span> ({{this['FileSize'] | divided_by: 1024 | round }} KB)  </p> 

Media Downloads is called by the following snipped on the page I want the list to appear:

{% component source: "mediaDownloads", layout: "List", type: "module" %}

I haven’t used Classifications for Media Downloads so haven’t looked at that aspect.

This will probably be replaced by the Treepl Migration Tool but it is useful to see what has to be considered, the effort required and perhaps how much work the Migration Tool will save.

3 Likes