-
-
Save MichalGrzegorzak/60955cb340cefe7127c0f85338e66be8 to your computer and use it in GitHub Desktop.
List all page types from a EPiServer CMS 7.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model IEnumerable<EPiServer.DataAbstraction.ContentType> | |
@{ | |
Layout = null; | |
} | |
@Html.Partial("PageTypeTablePartial", Model) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model IEnumerable<EPiServer.DataAbstraction.ContentType> | |
@{ | |
Layout = null; | |
} | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width" /> | |
<title>PageTypeInformation</title> | |
<style type="text/css"> | |
.gadget-body { | |
padding: 20px; | |
} | |
th { | |
font-weight: bold; | |
padding-left: 10px; | |
padding-right: 10px; | |
padding-top: 28px; | |
} | |
th:first-child, td:first-child { | |
padding-left: 0px; | |
} | |
th:last-child, td:last-child { | |
padding-right: 0px; | |
} | |
td { | |
line-height: 28px; | |
border-bottom: 1px solid #999; | |
padding-left: 10px; | |
padding-right: 10px; | |
} | |
tr.add-margin td { | |
padding-top: 32px; | |
} | |
td.no-border { | |
border-bottom: 0px solid #999; | |
} | |
.text-center { | |
text-align: center; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="gadget-body"> | |
<p> @Html.ActionLink("Export list as Excel", "ExportAsExcel", "PageTypeInformation", new { target = "_blank" }) </p> | |
@Html.Partial("PageTypeTablePartial", Model) | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Mvc; | |
using EPiServer.DataAbstraction; | |
using EPiServer.Shell.Gadgets; | |
using Website.Web.Gadgets.Models; | |
namespace Website.Web.Gadgets.Controllers | |
{ | |
[Gadget(Name = "Page type information", Title = "Page type information")] | |
[Authorize(Roles = "WebAdmins")] | |
public class PageTypeInformationController : Controller | |
{ | |
private readonly IContentTypeRepository _contentTypeRepository; | |
public PageTypeInformationController(IContentTypeRepository contentTypeRepository) | |
{ | |
_contentTypeRepository = contentTypeRepository; | |
} | |
public ActionResult Index() | |
{ | |
var model = new PageTypeInformationModel() | |
{ | |
ContentTypes = _contentTypeRepository.List() | |
}; | |
return View(model); | |
} | |
public ActionResult ExportAsExcel() | |
{ | |
Response.ContentType = "application/vnd.ms-excel"; | |
Response.AddHeader("content-disposition", " filename=pageTypeExports.xls"); | |
var model = new PageTypeInformationModel() | |
{ | |
ContentTypes = _contentTypeRepository.List() | |
}; | |
return View(model); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@model IEnumerable<EPiServer.DataAbstraction.ContentType> | |
@{ | |
Layout = null; | |
} | |
@if (Model != null) | |
{ | |
<table> | |
@foreach (var contentType in Model.Where(e => e.PropertyDefinitions.Count > 0).OrderBy(e => e.Name)) | |
{ | |
<tr> | |
<th>Page type display name</th> | |
<th>Page type name</th> | |
<th>Tab</th> | |
<th>Property display name</th> | |
<th>Property name</th> | |
<th>Language specific</th> | |
<th>Searchable</th> | |
</tr> | |
foreach (var propertyDefinitions in contentType.PropertyDefinitions.OrderBy(e => e.Tab.Name).ThenBy(e => e.Name)) | |
{ | |
<tr> | |
<td>@(string.IsNullOrEmpty(contentType.DisplayName) ? contentType.Name : contentType.DisplayName)</td> | |
<td>@contentType.Name</td> | |
<td>@propertyDefinitions.Tab.Name</td> | |
<td>@(string.IsNullOrEmpty(propertyDefinitions.TranslateDisplayName()) ? propertyDefinitions.Name : propertyDefinitions.TranslateDisplayName())</td> | |
<td>@propertyDefinitions.Name</td> | |
<td class="text-center">@((propertyDefinitions.LanguageSpecific) ? "x" : "")</td> | |
<td class="text-center">@((propertyDefinitions.Searchable) ? "x" : "")</td> | |
</tr> | |
} | |
} | |
</table> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment