Sunday, 22 May 2011

EPiServer File Manager & File Summary

A useful article about EPiServer File Manager and File Summary by @frederikvig. 


Highlights:

Accessing the data:

var file = System.Web.Hosting.HostingEnvironment.VirtualPathProvider.GetFile("/Global/Images/[Folder Name]/[Image-Name]") as UnifiedFile;

"The Summary property exposes a IUnifiedSummary type which gives us access to properties like Author, Comments, Category etc, and more importantly a Dictionary for accessing other properties we create (like Website)."

file.Summary.Dictionary["Website"]

Simple example of accessing the Summary properties in code:

<div class="featured">
 <img src="<%= Image.VirtualPath %>" alt="<%= Image.Summary.Title %>" />
 <p>
  <a href="<%= Image.Summary.Dictionary["Website"] %>"><%= Image.Summary.Author %>a>
  <em><%= Image.Summary.Dictionary["Description"]%>em>
 p>
div>

1 comment:

  1. That is exactly what I was looking for. Thanks for posting it.

    ReplyDelete