Skip to main content

Questions tagged [scriban]

For questions related to the SXA Scriban templates.

Filter by
Sorted by
Tagged with
5 votes
2 answers
6k views

Accessing Link Field Values in a Scriban Template

I am using a Scriban template in Sitecore 9.3 with SXA and am attempting to render a link field. While the sc_link function reliably generates the URL, I cannot seem to find a way to access any other ...
Sirius_B's user avatar
  • 601
5 votes
1 answer
2k views

Using Model in Scriban template

Is it possible to use the current Model in Scriban? I have a CutomHeroViewModel public class CustomHeroViewModel : VariantsRenderingModel { public string HeroTitle { get; set; } public string ...
user avatar
5 votes
1 answer
3k views

How can I do more complex loops in my Scriban templates?

I can loop through children like this: {{ for i_child in i_datasource.children}} But what if I only want the first 2, or if I want to skip the first 2 and take the next 3? Is this possible in scriban?...
Richard Seal's user avatar
  • 20.8k
4 votes
1 answer
1k views

How do you get value of item tag in scriban template

Sorry this is probably a dumb question but I am a bit stuck in here and I can't find suitable solutions in google. Basically I have an item or a page with a Tagging on it. But I can't seem to get the ...
keysl's user avatar
  • 155
4 votes
1 answer
1k views

How can I use Sitecore Rules in Scriban templates in SXA 9.3

In SXA 9.3 we have the possibility of using Scriban Templates. I wonder if there is a possibility to use Sitecore rules engine inside of those templates. Let say that I would like to render part of ...
Dawid Rutkowski's user avatar
4 votes
1 answer
1k views

How do you detect Edit Mode in the Experience Editor with Scriban?

Is there a function that I can use in the Scriban template to implement conditional logic based on the fact that the page is opened in the Experience Editor? Something like the below: <div class=&...
Andrey Bobrov's user avatar
4 votes
1 answer
2k views

Is there a way to parse Sitecore DateTime field type value in a particular Date or Time format directly in Scriban?

We are using SXA Rendering Variants with Scriban for our websites. In order to format the value of Sitecore field type DateTime in Scriban I am using `{{ sc_field i_item 'Date' [ [ 'format', 'd\nM,\...
Chetan Utture's user avatar
3 votes
2 answers
4k views

Scriban template split string

I have a pipe-separated string www.test.com | www.test1.com I want to get just the first string before the pipe that is www.test.com. How can I do this in the scriban template?
user avatar
3 votes
1 answer
656 views

Pipe expression destination `string.empty` is not a valid function

I'm trying to do something like {{ "" | string.empty }} and get Pipe expression destination 'string.empty' is not a valid function I can see it is available here though https://github.com/...
Mark Gibbons's user avatar
  • 5,717
2 votes
2 answers
2k views

Get Item by path or ID using Scriban in Sitecore

Environment: Sitecore 10.2 & SXA 10.2 Scenario: I would like to get the item by using its path or ID in Scriban. Is there any OOTB functionality to achieve this?
PSS's user avatar
  • 607
2 votes
1 answer
372 views

Handling multiple language versions of an Item in Scriban

Let's imagine I have an item with in three language versions: en, jp and es. My goal is to render a block which will display all 3 language versions of the item's 'Description' field. So, I would go ...
Andrey Bobrov's user avatar
2 votes
3 answers
184 views

Sitecore Scriban is not rendering fields when using dynamic field values

I have this Scriban template: {{ mediaId = sc_field i_item 'DropLinkField' item_By_Id = (sc_getitem mediaId) item_harcoded = "{ADAF43DF-BFD6-4444-9FE9-A030AB70B873}" get_the_url = ...
user8114149's user avatar
2 votes
1 answer
266 views

Object reference not set to instance in preview mode for sc_translate

I am getting object reference not set to instance at sc_translate in preview mode When i checked the scriban loc (10,57), it is sc_translate What can be the possible reason for this?
Jagmeet Kaur's user avatar
2 votes
1 answer
474 views

How to increment value and use it in sc_placeholder

Is it possible in Scriban to use the value from the variable, and then increment it and then use that value inside the sc_placeholder If it is not possible using the basic default Scriban, maybe ...
Samke11's user avatar
  • 389
2 votes
2 answers
85 views

How to get random 3 data from list of datasource item using scriban template

How to get random 3 data from a list of data source items using the Scriban template below query, I can get all data and show accordingly but I need random 3 data from a list of data sources. <div ...
md shahbaj's user avatar
2 votes
2 answers
544 views

How to render Sitecore Form using Sitecore Scriban Template

I need to render a Sitecore Form using the Sitecore Scriban Template. I see there is an implementation provided in Stack Exchange using MVC View. But is it possible using scriban?
Sitecore Learner's user avatar
2 votes
1 answer
874 views

Is there a way to do Scriban partial templates?

In MVC there's the concept of Partial Views which helps refactor common code that can be reused by other Views. Is there a similar concept in SXA Scriban? Ideal example: List of Links Template: {{ for ...
Mark Gibbons's user avatar
  • 5,717
2 votes
3 answers
645 views

Sitecore SXA search result count in scriban

Is there a way to read the search results count in a Scriban template in a rendering variant of SearchResult in SXA? I have a requirement that if the search results count is less than 6 the result ...
Christopher Raja's user avatar
2 votes
1 answer
2k views

How do you count the number of children in a Scriban template?

Given a page or item, how do I count the number of children? {{ i_page.children }}
Michael West's user avatar
  • 18.6k
2 votes
1 answer
2k views

Is there a way to get a user object in Scriban?

I was trying to display user information inside a Scriban template (SXA variant). I managed to write a context function that gives me the full name of the user (or any profile property I put in ...
Gatogordo's user avatar
  • 20.3k
2 votes
1 answer
38 views

Experience editor error for singleLineText

I'm encountering issues in Sitecore Experience Editor while using the following Scriban code in a rendering: {{sc_field Child "Latitude"}} Below is the error {"commands":[{"...
Sanjay Kumar's user avatar
2 votes
1 answer
73 views

How to Make an Image Field Non-Editable in Sitecore Experience Editor?

We are working on Sitecore 10.4 and using edit frames to make components editable with complex fields. However, I want to avoid making each field editable separately. For simple fields like the title, ...
Olive's user avatar
  • 75
2 votes
1 answer
368 views

Disable webedit for sc_field in Scriban?

I have a multi-line text field that I am rendering using scriban. the Field Content is an address some building, some floor some street PO box somePOboxNumber somecountry How can I render this field ...
Shaurya's user avatar
  • 457
2 votes
1 answer
1k views

How to get Media URL with custom width and media protection hash using Scriban

I need separate image fields for mobile and desktop and trying to render it using Scriban in picture tag as below. Current Scriban code: <picture> <source srcset="{{ i_item....
Harsh Baid's user avatar
  • 2,172
2 votes
1 answer
592 views

Customize Link rendering variant to append query string parameters

I want to customize an SXA link component with a rendering variant that appends query string parameters to the link based on fields on the page item. I'm using a Scriban template something like this: ...
Frank Rosario's user avatar
2 votes
1 answer
195 views

Sitecore SXA Dynamic Placeholders

We are trying to render dynamic placeholders with Scriban as follows: {{ sc_placeholder "relatedcontainer*" }} On our UAT instance the placeholder expands the wildcard out properly: ...
Joe Ouimet's user avatar
1 vote
3 answers
972 views

SXA Scriban Dynamic Placeholders

I am trying to render a dynamic placeholder with the Scriban as follows: {{ sc_placeholder 'section' }} and I would expect it to add a number to the key i.e. section-3, etc, but this is what I see as ...
Andrey Bobrov's user avatar
1 vote
2 answers
2k views

Scriban Rendering Parameters - how to get the value from Droplist?

I am trying to get the value from the Rendering Parameters in Scriban in order to render some new logic. Basically, I want to allow the content editors to choose what colour of the button they will ...
Samke11's user avatar
  • 389
1 vote
2 answers
742 views

Sitecore container with variants to change background color

I want to build a component in Sitecore that I can drag other components into when using Experience Accelerator, just like the out of the box container component. I'd also like to add variants on ...
natg504's user avatar
  • 25
1 vote
2 answers
140 views

How can i get data index for accordion using scriban sxa [duplicate]

I am trying to get data index for accordion items using scriban in sitecore sxa. Below is my scriban code. <div class="accordion accordion-flush" id="accordionFlushExample"> ...
Manish's user avatar
  • 87
1 vote
1 answer
562 views

How to get 'Alt' field value of Sitecore media item by Sitecore Scriban embedded method?

I am able to get the Sitecore media link by using the Sitecore Scriban Embedded method as follows: <img src="{{sc_follow i_article 'Thumbnail'| sc_medialink}}"> But, not sure how to ...
Prashant Tomar's user avatar
1 vote
2 answers
445 views

Facing error with SXA scriban template

I am trying to access the multilist field from datasource in scriban template and getting the following error. The code snippet is given below, <div class="row-section"> {{ for ...
manisha289's user avatar
1 vote
1 answer
233 views

Is there any way to edit partial design using Scriban?

Is it possible to style the partial design using the scriban template. For example, I just made the new header partial design for my new site, and I am now clueless on how to style it. I have been ...
Samke11's user avatar
  • 389
1 vote
1 answer
1k views

Is there a way to render scriban templates without the use of SXA Rendering Variants?

I would like to do some quick prototyping of scriban templates but have found constantly changing the rendering variant and refresh the page to be more time consuming than I would like. Is there a ...
Michael West's user avatar
  • 18.6k
1 vote
1 answer
5k views

Null checks in Scriban

I want to check for null values in Scriban. {{ if (o_model.address.id) }} <div style="text-align: center;"><h5>Address {{ o_model.address.id}}</h5><br /></div> ...
user avatar
1 vote
1 answer
127 views

Explanation of the 'JSON Template' within SXAs 'JSON Variants'

I am currently struggling a bit with understanding the capabilities of the JSON Variants in SXA. We are on SXA 9.3 and I want to make some customizations to the JSON representation with a JSON variant....
Simon's user avatar
  • 45
1 vote
1 answer
88 views

How to use a Static Binding in SXA Scriban

Is there a way to use a static Binding (View Rendering) in SXA Scriban Variant ?
Sylesh JL's user avatar
  • 191
1 vote
2 answers
1k views

How to use orderby in Scriban template?

I have to list my upcoming events on the web page. I have created the data source item for holding all the events and each event has event date. I'm using Scriban to display all the events. My ...
arul pushpam's user avatar
1 vote
1 answer
836 views

How to link static image asset from SXA using scriban

Sorry this is probably a dumb question but I can't seem to find anything related to it in google. Basically, I have a static image asset in my SXA Extension theme. e.g /sitecore/media library/...
keysl's user avatar
  • 155
1 vote
1 answer
3k views

How can I iterate through a list of links with Scriban?

I've created a template in Sitecore, and one of the fields in my template allows me to select an existing Link List item. I also have a Scriban variant where the code loops through all the items ...
natg504's user avatar
  • 25
1 vote
1 answer
1k views

Sitecore scriban how to fetch linked item from it's linked sub item?

I have a requirement to fetch the linked item from its linked sub item along with some linked item from the parent item's field. Below is the scenario. I have a "Landing Page" In the "...
Jey's user avatar
  • 373
1 vote
1 answer
1k views

Retrieving the href value of a Link field of Link item in scriban [duplicate]

I am trying to read the url value of Link field of Link item, append it with a query string and render the same as link. Below scriban does not work for the same. Any help please? {{ for i_child in (...
Christopher Raja's user avatar
1 vote
0 answers
30 views

How do I render a link caption on an o_model child item in a Scriban template?

We have a Rendering Variant that includes a Scriban template where we are iterating through the o_model.children_items like this: <ul> {{for page in o_model.children_items}} <li> ...
Harald Greve's user avatar
1 vote
1 answer
574 views

Error when adding scriban template to rendering variant migrated from 9.1.1 to 10.2

I'm currently in the process of upgrading our solution from Sitecore 9.1.1 to 10.2. Our solution has a number of nVelocity templates that I need to replace with scriban templates. I've also already ...
soze's user avatar
  • 123
1 vote
0 answers
52 views

Difference between scriban import and add

we are currently building a foundation in Sitecore SXA to process the external data using scriban context. Since we are to new scriban world and tried to understand how scriban processors are adding ...
user3774739's user avatar
1 vote
0 answers
227 views

Is there a way to access all of a page's components?

I want to create a custom scriban Processor and I need to access all of the renderings that have been put on the page. Is there a way to access that data?
Danny's user avatar
  • 147
0 votes
1 answer
424 views

Apply a CSS class to every alternative div using Sitecore SXA

I need to create an SXA component in which I need to apply a specific CSS class to each alternative div. The component should read the item from a multi-list and then render the HTML and apply a ...
Renuka's user avatar
  • 349
0 votes
1 answer
311 views

SXA component with rendering variant does not render if datasource is empty in the rendering

I am using an SXA component to render fields from current page. But it seems rendering variant renders fields only from datasource item. In my case, datasource is empty as I need to render fields from ...
Sitecoredev's user avatar
0 votes
2 answers
916 views

Using Sitecore link Manager in scriban script

I have a general link that is linking to an item in Sitecore. Path to linked item --> /sitecore/content/home/pageItemWithLayout I am using the below scriban script below to render the item link. &...
Shaurya's user avatar
  • 457
0 votes
1 answer
1k views

Search Result Listing Get index of an item using Scriban

I have a Search Result Listing Variant created using Scriban. This will render a card from each of the items got from the scope query. However, I want to get the index of items at the scriban template....
keysl's user avatar
  • 155