0

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 ( o_pagemode.is_experience_editor_editing ) }}
    <div style="display: flex; flex-direction: column; padding: 10px;">
        <div><b>Title:</b> {{ sc_field i_item 'Title'}}</div>
        <div><b>CssClass:</b> {{ sc_field i_item 'CssClass'}}</div>
        <div><b>Link:</b> {{ sc_field i_item 'Link'}}</div>
    </div>
{{ else }}
    {{ text = i_item.Title }}
    {{ linkInfo = (sc_link_info i_item 'link') }}
    {{ if linkInfo.text != "" }}
    {{ text = linkInfo.text }}
    {{ end }}

    <a href="{{ linkInfo.url }}" alt="{{ text }}" title="{{ text }}" >
        <svg>
            <use xlink:href="/img/abcd/xyz.svg#{{ i_item.CssClass }}"></use>
        </svg>
        <span class="myClass">{{ text }}</span>
        <i class="icon-indicator"></i> 
    </a>
{{ end }}

I am surely missing something here, and am thrown out with following error in just CD, while is ok in experience editor

/Component/d/Link(9,20) : error : The function sc_link_info was not found.

1 Answer 1

1

sc_link_info is not out of the box function.

It's a custom extension for Scriban which can be found on github: https://gist.github.com/auzick/c2e127ed4c6aef0f019eedc0ab738d2b

When you open page in Experience Editor, the else condition from 7th line of your code is not triggered, so the sc_link_info is not used. That's why you don't see exception in Experience Editor, only on CD server.

Here is more info how you can use the extension:

Accessing Link Field Values in a Scriban Template

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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