With the .NET Core renderer, clients can take full advantage of the new page editor of Sitefinity and its rich functionality.
It has a lot of improvements, one of which is a single widget, dedicated to creating in-page layouts, called Section.
Sections are placeholders for content widgets. They could be nested or configured to have multiple columns. By default, the section widget utilizes one of the most popular CSS grid systems—the Bootstrap 4 grid system. However, in case you have a preferred CSS frameworks or a CSS grid system, you can easily switch to using one of them.
In this tutorial we will do just that. We will learn how to replace the Bootstrap grid system with the Tailwind grid system.
The example in this blog post can be found as a sample project in Sitefinity .NET Core samples. The name of the project is "change-grid-system." If you're new to the subject, here's a great article about the Sitefinity Page Editor and the best ways to use it.
Let's get started.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss@1.4.6/dist/utilities.min.css" />
In case you need to override the default styles of the section widget, you could add the following link, which will replace the default section widget styles.
<link rel="stylesheet" href="@Progress.Sitefinity.AspNetCore.Constants.PrefixRendererUrl("styles/section.css")" type="text/css">
"Widgets":{
"Styling":{
"CssGridSystemColumnCount":12
}
}
ColumnProportions—an array, in which each item holds the number of css grid columns per a row column
ColumnsClasses—classes assigned to each row column from the UI
@addTagHelper *, change-grid-system
GridSize—the number of grid columns in the system - 12 in the case of Bootstrap and Tailwind;
AddtionalClass—all additional classes, set to the column, for example from the property editor's advanced view;
CssColsPerRowCol—number of grid coluimns per row column) which we'll pass through the section template.
[HtmlTargetElement(Attributes = "columnClass")]
public class ColumnClassTagHelpers : TagHelper
{
/// <summary>
/// Gets or sets the number of columns in the grid.
/// </summary>
public string GridSize { get; set; }
/// <summary>
/// Gets or sets the additional classes.
/// </summary>
public string AdditionalClass { get; set; }
/// <summary>
/// Gets or sets the number of grid columns per row column.
/// </summary>
public string CssColsPerRowCol { get; set; }
/// <summary>
/// Processes the output.
/// </summary>
/// <param name="context">The view context.</param>
/// <param name="output">The processed output.</param>
public override void Process(TagHelperContext context, TagHelperOutput output)
{
if (output != null)
{
output.Attributes.RemoveAll("columnClass");
var cls = string.Concat(this.AdditionalClass, " w-", this.CssColsPerRowCol , "/", this.GridSize);
output.Attributes.SetAttribute("class", cls);
}
}
}
In case you need to create completely custom sections/placeholders for your web page, you could take advantage of this example and this video.
If you found this tutorial useful, you’re welcome to give the Sitefinity page editor and section widgets a try. With a .Net Core renderer available out of the box, Sitefinity gives developers an extra level of flexibility in terms of frontend development. If you're new to Sitefinity, you can learn more here or jump right in and start your free 30-day trial today.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites