I have a Razor script that is pulling together documents within multiple folders in the Media Library and displaying those documents as a list of links to the associated document as a macro on the page. As it is now, everytime a document is added or changed in the Media Library folder that is used for the macro, all the previously added documents fail to be pulled into the Macro on the page. Is there a way to assure that the content of these Media Library folders will allways refreshed within the macro? Here is the Razor:
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
if ( String.IsNullOrEmpty(@Parameter.mediaFolder) ) {
<div><p>A folder has not been selected</p></div>
}
var folder = Parameter.mediaFolder;
var media = Library.MediaById(folder); @* was Model.MediaById(folder); *@
}
@helper traverse(dynamic node) {
var cc = node.Children;
if ( cc.Count()>0 && node.NodeTypeAlias == "Folder" ) {
<ul>
@foreach (var c in cc) {
<li>
@structure(c)
@traverse(c)
</li>
}
</ul>
}
}
@helper structure( dynamic node ){
if ( node.NodeTypeAlias == "Folder" ) {
<span class="folder" id="@node.Name.ToLower().Replace(" ", "_")">@node.Name</span>
} else {
<a href="@node.Url" target="_blank">@node.Name</a>
}
}
<div class="formWrangler">
@traverse(media)
</div>
Auto-Update of Media Content
I have a Razor script that is pulling together documents within multiple folders in the Media Library and displaying those documents as a list of links to the associated document as a macro on the page. As it is now, everytime a document is added or changed in the Media Library folder that is used for the macro, all the previously added documents fail to be pulled into the Macro on the page. Is there a way to assure that the content of these Media Library folders will allways refreshed within the macro? Here is the Razor:
This sounds like a problem with your Examine index not updating or corrupting as Examine is used a sort of cache for media. The Razor here looks fine.
is working on a reply...