Hot answers tagged

6

Yep! You can do it by adding Rule item under your Sriban template item and using sc_evaluate function inside of the template. Example: I have a page which has two fields: Title Brand And I want to render Brand field only when it is Monday. In order to do that I'm using Page Content rendering (can be any other) with following rendering variant: And the ...


6

Yes, it is possible. Keep in mind that Scriban by default is lower casing properties and using underscore to separate the words. So property called VariantFields will be accessible in Scriban by variant_fields. Take a look here: Please refer to the Scriban documentation for more details: https://github.com/lunet-io/scriban By default, Properties and ...


3

The reason why you cannot access those properties is because they are not know in the Scriban context provided by the SXA extensions. If you have i_item.CardLink in your Scriban template, that will match a Field object. This object has some properties (eg Target), but not the properties from a LinkField. And those are the ones you are requesting. There is a ...


2

First of all, you don't need to have a delegate there. It is useful when your function can accept optional parameters. You won't do it in Func and that is why we are using delegate. Otherwise, you can do something like that and skip delegate: args.GlobalScriptObject.Import("sc_link", new Func<Item, string>((item) => { // something return ...


1

You can try something like the following: {{- childrenCount = i_page.children | array.size -}} {{ childrenCount }}


1

I don't think there is an ootb way to do this (yet). A small extension could help you here. Something like this (not tested): public class MediaUrl : IGenerateScribanContextProcessor { private readonly IContext context; public MediaUrl(IContext context) { this.context = context; } public void Process(...


1

Instead of using {{i_item.Title }} you can use the raw value of the field, that will only render the fields contents and will not add the experience editor ability: {{i_item.Title.Raw }} This will work for Single/Multi-line text and RichText fields. For things like Images/Media, then you can construct the tag manually and use things like sc_medialink or the ...


1

Never mind, there was an error in my template code. I used i_item.Link, which renders the HTML for the link; when I should have used the i_item.url property instead. Once I fixed this, template worked as expected. {{ text = i_item.Name baseLink = i_item.url hasQsParam = (baseLink | string.contains '?') href = null if(hasQsParam) ...


1

Try using an extension. See https://gist.github.com/auzick/c2e127ed4c6aef0f019eedc0ab738d2b. using Scriban.Runtime; using Sitecore.Data.Fields; using Sitecore.Data.Items; using Sitecore.XA.Foundation.Abstractions; using Sitecore.XA.Foundation.Scriban.Pipelines.GenerateScribanContext; using System; namespace Example.ScribanExtensions.Pipelines { public ...


Only top voted, non community-wiki answers of a minimum length are eligible