Skip to content

Instantly share code, notes, and snippets.

View zealott's full-sized avatar

Douglas Rompasky zealott

View GitHub Profile
@zealott
zealott / SSL Check Base Tag
Created October 30, 2017 21:33
How to build your base tag (http://www.w3schools.com/tags/tag_base.asp) -- Added Base tag example from Ryan that checks for SSL cert variable and inserts the proper urlScheme if SSL is set.
//With the movement of SSL being a new web standard we need to start checking to see if SSL certificates are being hosted on a load balancer.
//The below code will check for the variable from a LB and insert the proper scheme if it is, otherwise revert to the current request.
//This is because when SSL is on the load balancer all traffic to the web server will be HTTP, but the client will be getting HTTPS.
var urlScheme = !string.IsNullOrWhiteSpace(Request.ServerVariables["HTTP_X_FORWARDED_PROTO"])
? Request.ServerVariables["HTTP_X_FORWARDED_PROTO"] : Request.Url.Scheme;
string baseUrl = string.Format("{0}://{1}{2}{3}", urlScheme, Request.Url.Host, Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port, Request.ApplicationPath);
if (!baseUrl.EndsWith("/"))
{
@zealott
zealott / Select, loop through, and call component views.cs
Created October 30, 2017 21:33
Demonstration of how to select and loop through a list of components while calling the appropriate partial view.
// Get the components, this statement gets all of them from the LeftSideColumnComponent list regardless of component type
IEnumerable<ICMSElement> leftSideColumnComponents = Model.Elements(null, "LeftSideColumnComponent");
// Loop through components and call view that matches root element name.
foreach (ICMSElement leftSideColumnComponent in leftSideColumnComponents)
{
//add a try/catch in case a view is missing
String compName = leftSideColumnComponent.RootElementName;
try
{
@zealott
zealott / In Context Editing (ICE)
Created October 30, 2017 21:33
Demonstration of how to use the @_Helpers.RenderICEAttribute for ICE (in context editing) compatibility.
@model Ingeniux.Runtime.ICMSElement
@using Ingeniux.Runtime
@{
// Set required ICE attribute using helper
<h1 @_Helpers.RenderICEAttribute(Model)>@Model.Value</h1>
}
@zealott
zealott / Populate form action with link value
Created October 30, 2017 21:33
Use the _Function.GetLinkAction function when you want to use a Link Element to populate the form element action attribute.
@zealott
zealott / SMTP test credentials
Created October 30, 2017 21:33
Use these internal SMTP credentials to test sending emails.
SMTP Server: mx.ingeniuxondemand.com
SMTP Server Port: 25
Authentication: anonymous
From Email: noreply@ingeniux.com
@zealott
zealott / Recommended Software.md
Created October 30, 2017 21:33
List of recommended software for Software Implementation Engineers.
// View (CSHTML)
// Add SquishIt namespace reference
@using SquishIt.Framework
// CSS bundling
@Html.Raw(Bundle.Css()
.Add("prebuilt/css/cssFile1.css")
.Add("prebuilt/css/cssFile2.css")
.Add("prebuilt/css/cssFile2.css")
.Render("prebuilt/css/combined-#.css"))
@zealott
zealott / Distinct Taxonomy Navigation Collection
Created October 30, 2017 21:33
In order to get a distinct IEnumerable<ICMSLinkElement> collection use _Functions.GetDistinctItems(). Since pages can be tagged with multiple categories this prevents duplicates of the same page in the IEnumerable<ICMSLinkElement> collection.
IEnumerable<ICMSLinkElement> exampleListing = _Functions.GetDistinctItems(Model.GetNavigationItems("NavigationElementName", NavigationElementType.TaxonomyNavigation, false, true));
@zealott
zealott / CSVResourceMap.cs
Created October 30, 2017 21:32
CSV Importer that matches CSV column headers to a new object. This was developed by Adam and then retrofitted to SAIT's specific needs. I figure this is a good place to put this so we can collectively refine it.
using CsvHelper.Configuration;
using Ingeniux.CMS.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Ingeniux.CMS.Applications
{
public class CSVPageWrapper
{
@zealott
zealott / example_variations
Created October 30, 2017 21:32
Examples of Grouping inner html tags using MoreLINQ Batch method and C# GroupBy() method. I personally think the MoreLINQ Batch method is the cleanest implementation.
double blockSize = 3d;
for (int i = 0; i < Math.Ceiling(filmNavigation.Count() / blockSize) ; i++)
{
<div class="playing-wrap">
@for (int j = i * (int)blockSize; j < (i * blockSize) + (int)blockSize && j < filmNavigation.Count(); j++)
{
<div class="inner-div">j</div>
}
</div>