Skip to content

Instantly share code, notes, and snippets.

@rbaty-barr
Created December 1, 2017 19:43
Show Gist options
  • Save rbaty-barr/c2e5572ce9fea66c7c307d7bb8d16a13 to your computer and use it in GitHub Desktop.
Save rbaty-barr/c2e5572ce9fea66c7c307d7bb8d16a13 to your computer and use it in GitHub Desktop.
forms and docs with mediapicker2
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
var mediaRoot = Model.Content.GetPropertyValue<IPublishedContent>("formsAndDocs");
}
<div id="formsDocsArea">
@if(mediaRoot != null && Model.Content.GetPropertyValue<string>("asHideShow") == "True"){
foreach( var item in mediaRoot.Children()){
if(item.ContentType.Alias =="Folder" && item.Children.Count() > 0){
@listFolders("hs", @item, @item.Descendants().Where(x => x.ContentType.Alias !="Folder").Count().ToString())
} else if(@item.ContentType.Alias !="Folder" && @item.ContentType.Alias !="Image"){
@listDloads("hs", @item)
}
}
} else if(mediaRoot != null && Model.Content.GetPropertyValue<string>("asHideShow") == "False"){
foreach( var item in mediaRoot.Children()){
if(item.ContentType.Alias =="Folder" && item.Children.Count() > 0){
@listFolders("bullet", @item, @item.Descendants().Where(x => x.ContentType.Alias !="Folder").Count().ToString())
} else if(item.ContentType.Alias !="Folder" && item.ContentType.Alias !="Image"){
@listDloads("bullet", @item)
}
}
}
</div>
@helper listFolders( string HowList, IPublishedContent theFolder, string itemCount )
{
if(HowList == "hs")
{
<div class="panel-group @theFolder.Name.Replace(" ", "").ToLower()" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" href="#collapse@{@theFolder.Id}"><i class="fa fa-plus-circle"></i> @theFolder.Name (@itemCount)</a>
</h4>
</div>
<div id="collapse@{@theFolder.Id}" class="panel-collapse collapse">
<div class="panel-body">
@foreach(var item in theFolder.Children){
if(item.ContentType.Alias =="Folder" && item.Children.Count() > 0){
@listFolders("hs", @item, @item.Descendants().Where(x => x.ContentType.Alias !="Folder").Count().ToString())
} else if(item.ContentType.Alias !="Folder" && item.ContentType.Alias !="Image"){
@listDloads("hs", @item)
}
}
</div>
</div>
</div>
</div>
} else if(HowList == "bullet") {
<h2>@theFolder.Name</h2>
<ul class="list-unstyled">
@foreach(var item in theFolder.Children){
if(item.ContentType.Alias =="Folder" && item.Children.Count() > 0){
@listFolders("bullet", @item, @item.Descendants().Where(x => x.ContentType.Alias !="Folder").Count().ToString())
} else if(item.ContentType.Alias !="Folder" && item.ContentType.Alias !="Image"){
@listDloads("bullet", @item)
}
}
</ul>
}
}
@helper listDloads( string HowList, IPublishedContent theItem ){
if(HowList == "hs")
{
<p><a href="@theItem.Url" target="_blank" class="docList">@theItem.Name</a></p>
} else if(HowList == "bullet") {
<li><a href="@theItem.Url" target="_blank" class="docList">@theItem.Name</a></li>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment