0

I am using a Link component and I want to make the 'Link Description' field a dynamic value. Is there a way to set the 'Link Description' value from the CMS side?

enter image description here

2
  • 1
    Can you share details about what value you want to put dynamically in the Link Description and why? If that value is present in the datasource/context, you should set link description with that value while rendering this link field without saving it in the field xml. If you still want the dynamic value to be saved in field's xml (visible when you check Raw Value for the field), you can create handler which on item save can look for the field and update its xml to set the description to your dynamic value. There are more approaches too but need to understand the requirement first.
    – Ghan
    Mar 24, 2023 at 7:27
  • Yes, Ghanendra. I used a dynamic link description field from the Data folder and wrote a JS to read that data and update the innerHTML. Thank you for your comment. Mar 30, 2023 at 4:57

1 Answer 1

0

If you do not want to use this existing field, create your custom field called "Display Text", In your link component your custom class, and in JS when you get that class replace innerHTML of with your display text field value

Otherwise there are longer routes too of extending the item save and update it

2
  • This works for me. Thanks a lot for your input here. After creating an additional field to insert the custom filter title, I used a JS to read that value and replace the innerHTML to display the custom title in Link Component. Mar 30, 2023 at 4:55
  • Good to know :) Apr 13, 2023 at 7:34

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.