1

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 created with that template. When I try to output the Link List field, I only get the name of the list, rather than the list of links. How can I display the actual list of links?

    <!-- loop through the parent items -->
{{ for i_parent in i_datasource.children }}                     

    <!--loop through the child items -->
    {{ for i_child in i_parent.children }}   
            
        <!-- link -->
        {{ if (i_child.Link) }}
            <p class="linkstyle">{{i_child.Link}}</p> 
        {{end}}

        <!-- description -->
        {{ if (i_child.Description) }}
            <p class="description"> {{i_child.Description}}</p>
        {{end}}

        <!-- link  list -->
        {{ if (i_child.LinkList) }}
            <!-- this displays the list name -->
            {{i_child.LinkList}}      

            <!-- TO DO: display the list of links, not just the link list name -->
            {{ for i_product in (sc_followmany i_item i_child.LinkList) }} 
                <!-- this displays nothing -->
                <span class="linkstyle">{{i_product.name}}</span>
            {{end}}
        {{end}}

    {{ end }} 

{{ end }} 
0

You are using the sc_followmany with the wrong parameters. It needs these:

  • Item for which the value of the field is retrieved
  • Name of the field that links to items

(see https://doc.sitecore.com/developers/sxa/93/sitecore-experience-accelerator/en/the-embedded-functions-for-the-scriban-template.html)

I your case that would be sc_followmany i_child "LinkList" or use the (shorter) extension like this: i_child.LinkList.targets

4
  • It's still not displaying anything. I tried {{ for i_product in (sc_followmany i_child "LinkList") }} and {{ for i_product in i_child.LinkList.targets }} . It's not even going into the loop. Could it be a problem with the list? – natg504 Mar 10 at 18:18
  • Is LinkList actually the name of your field? And which type is that field? – Gatogordo Mar 10 at 19:56
  • Yes, the field is named "LinkList" type is Droplist, source is "/sitecore/content/MyTenant/MySite/Data/Link Lists" – natg504 Mar 10 at 20:54
  • Oh, a DropList.. that won't work. A droplist stores the names of the selected items, and not a link (guid) to it. You should use a droplink field instead. – Gatogordo Mar 11 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.