Skip to content

Instantly share code, notes, and snippets.

View naepalm's full-sized avatar

Janae Cram naepalm

View GitHub Profile
@naepalm
naepalm / Pagination.cshtml
Last active December 22, 2021 12:29
A "quick & easy" razor pagination to plug into an Umbraco View, Partial View, or Macro
@{
var pageSize = 8;
if(Model.Content.HasValue("numberOfItemsPerPage")){
pageSize = Model.Content.GetPropertyValue<int>("numberOfItemsPerPage");}
var page = 1; int.TryParse(Request.QueryString["page"], out page);
var items = Umbraco.TypedContent(Model.Content.Id).Children.Where(x => x.DocumentTypeAlias == "exampleAlias" && x.IsVisible()).OrderByDescending(x => x.CreateDate);
var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize);
if (page > totalPages)
@naepalm
naepalm / TextPage.cshtml
Last active March 21, 2016 17:22
Basic text page template content with headings & general content for styling
@inherits UmbracoViewPage<TextPageViewModel>
@using Client.Web.Models.ViewModels
@{
Layout = "OneColumn.cshtml";
}
<section id="primary" class="col-s-8 offset-s-2">
@*Model.BodyText*@
<h1>Heading 1</h1>
@naepalm
naepalm / Editors\Base.cshtml
Last active October 30, 2017 20:20
Grid view & controls for Skybrud's strongly typed models with Responsive BP
@model GridControl
@using Grid.Web
@using Skybrud.Umbraco.GridData
@try
{
<text>@Html.Partial(Model.EditorView(), Model)</text>
}
catch (Exception ex) {
<pre>@ex.ToString()</pre>
@naepalm
naepalm / FAQListing.cshtml
Last active October 8, 2019 23:45
An example of different ways to code the Umbraco FAQ Package's content.
@using FAQ
@inherits UmbracoTemplatePage
@{
Layout = null;
}
<h1>@Model.Content.Name</h1>
<h2>Render All FAQ Items</h2>