Questions tagged [scriban]
For questions related to the SXA Scriban templates.
61 questions
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>
...
0
votes
1
answer
75
views
Can't read Tag title
I can't read tag title in scriban in sitecore while I can reach out the path and the display name correctly
the code I use to read title:
indTags = i_item.ProductIndustryTags.targets
{{- for ind in ...
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: ...
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":[{"...
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, ...
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 ...
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 = ...
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 ...
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....
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 ...
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">
...
0
votes
1
answer
101
views
Using sc_link_info on Scriban template throwing error
I am new to Sitecore sxa, I have got SXA Scriban template being used in rendering variant. as
/Component-x/default/Link
and this Link has a field where following snippet is provided.
{{ if ( ...
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?
0
votes
2
answers
213
views
how can we get general link field from rendering parameter in sitecore sxa using scriban
I am trying to access general link field from rendering parameter in sitecore sxa using scriban
but it is accessing whole link tag with page id instead of url.
how can get normal url?
<a class=&...
0
votes
2
answers
525
views
How to have dynamic placeholders within the for loop?
I am trying to make the dynamic placeholders with different numbers in the for loop. Now when I make the placeholder I only get the same name and number at the end (test-1-1). How to make it so that ...
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 ...
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?
0
votes
0
answers
56
views
JSON template in Sitecore 10.1
Is there any alternate to JSON template in Sitecore 10.1?. We migrated to Sitecore 10.1 from Sitecore 8.
One of the Rendering Variants is JSONResults, which includes JSON Template inside JSONResults. ...
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 ...
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 ?
0
votes
1
answer
569
views
How to form a Page URL of wildcard item in scriban
I have created a variant to list down data source items using result variant selector and all these data items will need to point to wildcard content item .How to form URL of wildcard item in Scriban?
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 ...
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?
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 ...
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 ...
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 ...
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/...
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 ...
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 ...
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 ...
0
votes
0
answers
27
views
How to check the length of selected items in for loop using Scriban? [duplicate]
Is there a way to check how many items are selected from Treelist using Scriban? What I want to do is that if there is only one item selected then display something, if there is more than two then ...
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 ...
0
votes
1
answer
5k
views
Scriban - How to check if the value of certain general link field is null [duplicate]
Is there any way to check if the value of a field is empty or to be more precise value in general link field is empty in Scriban?
Whenever I type the if keyword, it does not register it:
Here is the ...
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?...
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.
&...
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 ...
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 ...
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 ...
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 ...
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....
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 ...
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,\...
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 ...
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 ...
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=&...
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/...
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?
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 ...
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 (...
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 ...