0

I have a Drupal 9 site that has a content type of "Venue", I want to add a link field to this content type and show the URL (plain text) in the template.

I have tried using content.field_cta.0['#url'].toString() but nothing is returned.

There is another link field on this content type where the exact same twig code works as expected.

How can I get the URL of the new field visible on the node template as plain text?

1 Answer 1

0

Just check your new link field machine name and call with that machine name like content.your_new_field_machine_name.0['#url'].toString().

If it does not work check with dump(content) and check the exact variable name of your newly added link.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.