So you jumped in head first into Scriban Templates with Sitecore. And now you hit a wall because it doesn't do that one thing you could easily have completed in MVC forms with a controller. Well, this is where you can build your own custom functions to work within Scriban templates. Sitecore already provides a few of these at https://doc.sitecore.com/developers/sxa/93/sitecore-experience-accelerator/en/the-embedded-functions-for-the-scriban-template.html . So How Do You Build Your Own? Well let's begin by discussing what we want to build. In our project we have a need to get the nearest parent of a certain template type. This way we can determine if the page you are viewing is part of a conference section or not. So first, let's build the C# code that will execute when we call the function. We decided to add a new member to the i_item to determine if we were in a conference context and allow us to call other properties as we would need. public class GetConferenceC
With the Scriban syntax being new to the Sitecore platform with v9.3 there is definitely a learning curve but well worth the time investment. So we will post short tips on things that we struggled with. This is to share but also I will have a place to find it again when I need it. So you've created a date field in your Sitecore template and now need to format it for display purposes. Or even better, you have styling differences depending on if the dates and years match for start and end points. Let's show this below. First, get the date(s) in your Scriban template from the item. In this scenario I was looping through child objects called i_child. Using the Scriban date.parse function I can get the date value from the Sitecore field by this: {{ this.startDate = sc_field i_child 'Event Start' | date.parse; this.endDate = sc_field i_child 'Event End' | date.parse; }} Now that we have the date values you can do things to check against