Skip to content

Instantly share code, notes, and snippets.

@sotirisf
Created December 13, 2020 18:50
Show Gist options
  • Save sotirisf/17c8df5f1f8f4f7158ed82f20e0a238f to your computer and use it in GitHub Desktop.
Save sotirisf/17c8df5f1f8f4f7158ed82f20e0a238f to your computer and use it in GitHub Desktop.
@inherits UmbracoViewPage<Umbraco.Core.Models.Blocks.BlockListItem>
@{
switch (Model.Content.ContentType.Alias)
{
default:
var controllerContext = Html.ViewContext.Controller.ControllerContext;
var result = ViewEngines.Engines.FindPartialView(controllerContext, "SectionScripts/" + Model.Content.ContentType.Alias + "Scripts");
if (result.View != null)
{
@Html.Partial("SectionScripts/" + Model.Content.ContentType.Alias + "Scripts", Model)
}
break;
}
}
@using Umbraco.Web.PublishedModels;
@using System.Configuration;
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@{
if (!(Model is IAbstractPageSections)) { return; }
var introBlock = (Model as IAbstractPageSections).IntroSection;
if (introBlock.Any(x => (x.Content as IAbstractSectionBlock).Disabled == false))
{
@Html.Partial(MVC.Shared.Views.Common._RenderSectionScripts, introBlock.Where(x => !(x.Content as IAbstractSectionBlock).Disabled).FirstOrDefault())
}
var blocks = (Model as IAbstractPageSections).Sections;
if (!blocks.Any()) { return; }
bool unifySectionScripts = ConfigurationManager.AppSettings.Get("UnifySectionScripts")?.ToLower() == "true";
System.Text.StringBuilder sb = new System.Text.StringBuilder(string.Empty);
foreach (var block in blocks.Where(x => (x.Content as IAbstractSectionBlock).Disabled == false))
{
if (block.Content.ContentType.Alias.Equals(SectionMultiColBlock.ModelTypeAlias))
{
foreach (var innerBlock in (block.Content as SectionMultiColBlock).Items)
{
sb.Append
(Html.Partial(MVC.Shared.Views.Common._RenderSectionScripts, innerBlock));
}
}
else
{
sb.Append
(Html.Partial(MVC.Shared.Views.Common._RenderSectionScripts, block));
}
}
if (unifySectionScripts)
{
sb.Replace("<script type=\"text/javascript\">", "");
sb.Replace("<script>", "");
sb.Replace("</script>", "");
sb.Replace("\r\n\r\n", "\r\n");
@Html.Raw("<script type=\"text/javascript\">")
@Html.Raw(sb.ToString())
@Html.Raw("</script>")
}
else
{
@Html.Raw(sb.ToString())
}
}
@inherits Umbraco.Web.Mvc.UmbracoViewPage<Umbraco.Core.Models.Blocks.BlockListItem>
@{
SectionClientLogosBlock currSection = Model.Content as SectionClientLogosBlock;
SectionClientLogosBlockSettings settings = Model.Settings as SectionClientLogosBlockSettings;
int count = currSection.Items.Count;
}
<script type="text/javascript">
$(document).ready(function () {
$('#section_' + '@currSection.Key.ToString()' + ' .client-carousel').owlCarousel({
autoPlay: @((!settings.ManualPlay).ToString().ToLower()),
autoHeight: @settings.AutoHeight.ToString().ToLower(),
stopOnHover: @settings.StopOnHover.ToString().ToLower(),
slideSpeed: (@settings.SlideSpeed==0 ? 400 : @settings.SlideSpeed),
items: @(count < 5 ? count : 5),
itemsDesktop: [1170, @(count < 4 ? count : 4)],
itemsDesktopSmall: [1024, @(count < 3 ? count : 3)],
itemsTabletSmall: [768, @(count < 2 ? count : 2)],
itemsMobile: [480, 1],
pagination: @settings.ShowBullets.ToString().ToLower(), // Show pagination buttons
navigation: @settings.ShowNavigationButtons.ToString().ToLower(), // Hide next and prev buttons
navigationText: ["<i class='fa fa-angle-left'></i>", "<i class='fa fa-angle-right'></i>"]
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment