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 have. I have set up the class names for the colours and everything regarding the frontend part. Now, I only need to get the values from the Droplist since I am using that as a rendering parameters type of datasource.
Here is what I mean by this:
This is the component properties for this specific component called Sign up section. When user selects for example Gold
from the Droplist i want to change the button colour to gold.
Here is the template for rendering parameters:
And here is the Scriban
template:
{{
buttonColor = ""
if (sc_parameter "Button Color" != null)
parameter = sc_parameter 'Button Color'
buttonColor = ".button-new-sign {{parameter}}"
end
backgroundColor = sc_parameter 'Background Color'
icon = sc_parameter 'Icon'
}}
<div class="call-to-action call-to-action-fullwidth call-to-action-signup" style="background-color: {{backgroundColor}};">
<div class="container">
<div class="call-to-action-content">
<div class="row flex-md-nowrap justify-content-center">
<div
class="col-12 col-md-auto flex-shrink-1 d-flex flex-column flex-md-row align-items-center justify-content-center">
<svg class="call-to-action-icon icon icon-email">
<use xlink:href="#icon-email"></use>
</svg>
<h2 class="call-to-action-title text-center text-md-left">
{{sc_field i_item "Sign Up Text"}}
</h2>
</div>
<div class="col-12 col-md-auto text-center my-auto">
{{ if sc_parameter "Button Color" != "" }}
<div class="call-to-action-button {{buttonColor}}">
{{ sc_beginfield i_item 'Sign Up Link' [['text', ' ']]}}
{{ sc_link_text i_item 'Sign Up Link' }}
{{ sc_endfield }}
</div>
{{else}}
<div class="call-to-action-button button button-white">
{{ sc_beginfield i_item 'Sign Up Link' [['text', ' ']]}}
{{ sc_link_text i_item 'Sign Up Link' }}
{{ sc_endfield }}
</div>
{{ end }}
</div>
</div>
</div>
</div>
</div>
How to get the Value
field from the Colors item, or I can not do that since I am using droplist. Does anyone suggest any other way of doing this?