1 vote

File Picker Data Type

This package adds File Picker and Multiple File Picker data types to Umbraco 7.

 

They can be configured to list files from a specific folder, or search recursively, and filter for specific patterns.  

The user can then select one, or more with the MultipleFilePicker, file and save.  This package will not actually do anything with the file, but your custom template code can use the selected file as needed.

 

An optional link can be added to open the file, and an edit link that executes javascript.  To trigger the internal editor for css or javascript files use one of these values.

Css Edit Link: parent.openStylesheet("{0}");

Javascript Edit Link: parent.openScriptEditor("{0}");

 

An example to let editors select and attach additional Css and Js files to a document:

 

Extra Css Data Type:

Starting Folder: /css

Search Pattern: *.css

Alias on Document Type: cssInclude

 

Extra Script Data Type:

Starting Folder: /scripts

Search Pattern: *.js

Alias on Document Type: jsInclude

 

// Template code to inject extra resources into ClientDependency.  Script and Link tags could also be rendered directly.

@using ClientDependency.Core

@using ClientDependency.Core.Controls

@using Newtonsoft.Json.Linq;

 

var cdl = Context.GetLoader();

var allDependencies = ;

foreach(var item in GetFileList()) {

cdl.RegisterDependency(item.Priority, item.FilePath, item.PathNameAlias, item.DependencyType);

}

 

@functions 

{

    List<IClientDependencyFile> GetFileList()

    {

        var allDependencies = new List<IClientDependencyFile>();

 

        int priority = 20;

        if(Model.Content.HasProperty("cssInclude") && !String.IsNullOrEmpty(Model.Content.GetPropertyValue<string>("cssInclude"))) {

            foreach(var item in Model.Content.GetPropertyValue<JArray>("cssInclude"))

            {

                allDependencies.Add(new CssInclude { PathNameAlias = "Styles", FilePath = (string)item, Priority = priority++ });

            }

        }

 

        priority = 20;

        if(Model.Content.HasProperty("jsInclude") && !String.IsNullOrEmpty(Model.Content.GetPropertyValue<string>("jsInclude"))) {

            foreach (var item in Model.Content.GetPropertyValue<JArray>("jsInclude"))

            {

                allDependencies.Add(new JsInclude { PathNameAlias = "Scripts", FilePath = (string)item, Priority = priority++ });

            }

        }

        return allDependencies;

    }

 

}

Screenshots

Archived files

Documentation

Source code

Package owner

Jeremy Pyne

Jeremy Pyne

Jeremy has 244 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
8.1.x (untested)
8.0.x (untested)
7.14.x (untested)
7.13.x (untested)
7.12.x (untested)
7.11.x (untested)
7.10.x (untested)
7.9.x (untested)
7.8.x (untested)
7.7.x (untested)
7.6.x (untested)
7.5.x (100%)
7.4.x (untested)
7.3.x (untested)
7.2.x (untested)
7.1.x (untested)
7.0.x (untested)
6.1.x (untested)
6.0.x (untested)

You must login before you can report on package compatibility.

Package Information

  • Package owner: Jeremy Pyne
  • Created: 05/02/2016
  • Current version 1.0
  • .net Version 4.5
  • License MIT
  • Downloads: 360