How can we help you today?

How to Map File Type Icons for Document Library Files Inside Folders

Do you have a Document Library folder with different file types inside?


sample Document library folder


By default, when you connect to a File List Design Element using the REST API connection, you don’t have the option to map the appropriate file type icon for each document:


default connected file list


This article will demonstrate how you can do so using the advanced settings of ShortPoint Connect:


File List with correct file type icons


TABLE OF CONTENTS


Prerequisites

  • You must have the latest version of ShortPoint SPFx installed on your SharePoint environment.
  • You must be a ShortPoint Designer with an active license.
  • You must already have a File List Design Element on your page.
  • You must have a Document Library folder with different file types inside:


document library with different file types


Step-by-step Tutorial

Follow the detailed guide below to learn how to map file type icons:


Step 1: Edit the ShortPoint Web Part

Go to the SharePoint page you want to use and click Edit:


Edit


Close the Toolbox:


close icon


Click the Edit Properties icon:


Edit properties icon


Step 2: Switch to Grid Mode


NOTEShortPoint Connect is currently only available in Grid Mode.


Click the Switch to Grid Mode icon:


switch to grid mode icon


Step 3: Edit the File List Design Element


NOTEBefore proceeding, make sure you already have the File List Design Element on your page. If you don’t have it yet, check out How to Customize the File List Design Element. 

File List Design Element


Hover over the File List Design Element and click the cogwheel icon:


cogwheel icon


Step 4: Prepare REST API URL


NOTEBefore proceeding, make sure you have a Document Library folder with different file types inside: 

Document Library


Copy the REST API URL below:

https://YourSiteName/_api/web/GetFolderByServerRelativeUrl('DocumentLibrary/TargetFolder')/Files?$orderby=Name

Replace the following items:

  • YourSiteName - change to the site URL of your SharePoint site.
  • DocumentLibrary - change to the name of the Document Library you’ll use.
  • TargetFolder - change to the name of the folder you’ll use.


Here is an example of how your URL may look:

https://mycompany.sharepoint.com/sites/HR/_api/web/GetFolderByServerRelativeUrl('Policies/HR')/Files?$orderby=Name

where:

  • mycompany.sharepoint.com/sites/HR is the URL of our site;
  • Policies is the name of our Document Library;
  • HR is the name of our target folder.

Step 5: Connect to REST API

Go to the Connect tab:


Connect tab


Select REST API:


REST API


Paste the URL you prepared in Step 4 in the field provided:


paste URL


Step 6: Enable Advanced Settings

Scroll down and turn on Enable Advanced Settings:


Enable Advanced Settings


Copy the code below:

var resultsWithType = data.d.results.map(function(item) {    
    if(item.Name != null) {        
        var lastDotPosition = item.Name.lastIndexOf('.');
        item['Type'] = item.Name.substring(lastDotPosition + 1, item.Name.length);        
    }
    return item;
});

return resultsWithType;

Scroll down and paste the copied code in the Map Results field:


paste in map results


Click Connect:


Connect


Step 7: Map Items

Go to the Items tab:


Items tab


Use the link icon to map the properties you want to be shown:


link icon


Below are the properties we mapped. You can map the same properties or choose your own. Just make sure to use the same property in the File Type field so that the right file format will be shown:

  1. #Name - shows the file name as the title.
  2. #TimeLastModified - shows the date the file was last modified as the subtitle.
  3. #Type - shows the file format of the file.
  4. #LinkingUri - redirects to the actual file.


sample mapped properties


Click Preview to see how the Design Element will look:


Preview


Once satisfied, click Update:


Update


Step 8: Save

Click the eye icon to see your page in real-time:


eye icon


Save your changes:


Save


That’s it! You can now showcase the right file type icon for your connected File List Design Element.


connected file list


Related articles:

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 36 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more