0

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? enter image description here

<a class="btn btn-primary" href="{{ sc_parameter 'Specialist1' }}">test</a>

I am using above given code to render the field from rendering parameter

2 Answers 2

1

When you use sc_parameter that way, you get the raw value of the field, instead of link information.

You can use sc_field and pass your css classes as parameters like:

{{ sc_field i_item 'Specialist1' [['class', 'btn btn-primary']] }}

Scriban documentation can be found here:

https://doc.sitecore.com/xp/en/developers/sxa/103/sitecore-experience-accelerator/the-embedded-functions-for-the-scriban-template.html

2
  • thanks Marek issue got resolved Commented Nov 18, 2023 at 12:46
  • If my answered helped you, mark it as a correct one so it can help others in the future.
    – Marek Musielak
    Commented Nov 20, 2023 at 7:07
0

sc_parameter just gives you the raw values for Internal and External link and that is the reason you are getting the html as the result.

So if you need to get the URL you might need to consider creating custom scriban functions as described in https://blogs.perficient.com/2020/08/03/sxa-scriban-creating-custom-embedded-function-in-scriban/ and using the General Link related logics in your custom scriban function.

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.