Forum Discussion
(Updated this for a little more clarity)
The only way I can think of to do this is a little complicated and kludgy, and involves using a combination of Freemarker templates and Javascript/JQuery.
If it were me, I would do something like this:
Create a new component to replace the Add New (Ask a Question about X Product) button, in this case, script.AddLabelsButton.ftl, in order to have the button link to the New Message page with added parameters, i.e., ?parameter1=Xproduct¶meter2=moreInfo and put that component in the proper quilt, replacing the OOTB button with something similar to this:
<div class="btn">
<a href="/t5/tkb/articleeditorpage/tkb-id/sample-page/template-id/freeform?myparams=values"/>
</div>
Then in the custom component I've named script.AddLabelsButton.ftl custom component, I would get the parameters from the url via
<#attempt>
<#assign param1 = env.context.component.getParameter("param1")!"" />
<#recover>
<#assign tagName = "" />
</#attempt>
Then in the Javascript/JQuery section of script.AddLabelsButton.ftl I'd find the labels input field and add the new value, something like
$labelsSet.val($('#lia-labels').val()+'${param1}');
And that should add the label to the article when submitted. Make sure that the settings for the page allows for either custom labels, or that you have the various products/pages as predefined labels if that's what you're using.
You could do something like that for tags if you prefer.
So the final component in completed order would be something like:
<#attempt>
<#assign param1 = env.context.component.getParameter("param1")!"" />
<#recover>
<#assign param1 = "" />
</#attempt>
<script>
;
(function ($) {
$(document).ready(function () {
$('#lia-labels').val($('#lia-labels').val()+'${param1}');
});
})(LITHIUM.jQuery);
</script>
<div class="btn">
<a href="/t5/tkb/articleeditorpage/tkb-id/sample-page/template-id/freeform?param1=snacks"/>
</div>
Related Content
- 3 months ago
- 2 years ago
- 9 months ago
- 7 years ago