Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Call to Action Button for salted template in umbraco grid
@inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
@if (Model.Items.Any())
{
var isFrontEnd = Lecoati.LeBlender.Extension.Helper.IsFrontEnd();
foreach (var item in Model.Items)
{
IPublishedContent theNode = Umbraco.TypedContent(item.GetValue<string>("actionLink"));
var theSource = Umbraco.TypedContent(theNode.Parent.Id).GetPropertyValue<string>("source").Replace(" ","-");
var theCampaign = Umbraco.TypedContent(theNode.Parent.Id).Name.Replace(" ","-");
if(isFrontEnd){
var templateName = UmbracoContext.Current.PublishedContentRequest.TemplateAlias;
var theStuff = Lecoati.LeBlender.Extension.Helper.GetCurrentContent();
var newLine = "%%newLine%%";
var buttonColor = "#005cb9";
var btnTxtColor = "#FFFFFF";
if(templateName =="CampaignSibson"){
buttonColor = "#d3282f";
}
if(templateName =="CampaignSRC"){
buttonColor = "#007548";
}
if(templateName =="CampaignSegalMarco"){
buttonColor = "#007548";
}
if(templateName =="CampaignRogerscasey"){
buttonColor = "#007548";
}
if(templateName =="Test"){
buttonColor = "#333333";
}
var btnAlign = item.GetValue<string>("alignButton") != "" ? item.GetValue<string>("alignButton").ToLower() : "left";
var CTAlink = theNode.GetPropertyValue("linkUrl");
//var checker = CTAlink.ToString().Contains("?") ? "yes" : "no";
var queryChar = CTAlink.ToString().Contains("?") ? "&" : "?";
<tr>
<td>
<!-- BULLETPROOF BUTTON -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="mobile-button-container">
<tr>
<td align="@btnAlign" style="padding-top: 20px;" class="button-padding"> <!-- class="padding-copy" -->
<table border="0" cellspacing="0" cellpadding="0" class="responsive-table">
<tr>
<td align="@btnAlign"><a href="@(item.GetValue<string>("actionLink") != "" ? Umbraco.TypedContent(item.GetValue<string>("actionLink")).GetPropertyValue("linkUrl") : "#")@(queryChar)utm_source=@(theSource)&utm_medium=email&utm_campaign=@(theCampaign)" target="_blank" style="font-size: 18px; font-family: Arial, sans-serif; font-weight: normal; color: @btnTxtColor; text-decoration: none; background-color: @buttonColor; border-top: 8px solid @buttonColor; border-bottom: 8px solid @buttonColor; border-left: 25px solid @buttonColor; border-right: 25px solid @buttonColor; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; display: inline-block;" class="mobile-button">@Html.Raw(@item.GetValue("buttonText")) &#8250;</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
} else {
var templateStuff = Lecoati.LeBlender.Extension.Helper.GetCurrentContent();
var templateName = templateStuff.TemplateId;
var buttonColor = "#005cb9";
var btnTxtColor = "#FFFFFF";
var btnAlign = "left";
if(templateName == 1115){
buttonColor = "#d3282f";
}
btnAlign = item.GetValue<string>("alignButton").ToLower();
<div style="text-align: @btnAlign ;">
<div style="font-size: 16px; font-family: Arial, sans-serif; font-weight: normal; color: @btnTxtColor; text-decoration: none; background-color: @buttonColor; border-top: 15px solid @buttonColor; border-bottom: 15px solid @buttonColor; border-left: 25px solid @buttonColor; border-right: 25px solid @buttonColor; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; display: inline-block;" class="mobile-button">@Html.Raw(@item.GetValue("buttonText")) &#8250;</div>
</div>
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment