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?
-
1Can 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.– GhanCommented 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.– Anjali NirmaniCommented Mar 30, 2023 at 4:57
Add a comment
|
1 Answer
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
-
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. Commented Mar 30, 2023 at 4:55
-