By jhueck on
I have a custom content type with a field for a link. The link is supposed to be shown in an iframe.
in my node--databasemindmap2.html.twig I have the following code:
<div{{ content_attributes.addClass('node__content', 'clearfix') }}>
{{ content }}
<iframe width='100%' height='400' src="{{ content }}" frameborder='0' allowfullscreen></iframe>
<iframe width='100%' height='400' src="https://embed.coggle.it/diagram/XuKtbuRfjXG6iCwu/5324c954d5551b60def4c049825932a7a236523bbd7111d899425652c3ee7254" frameborder='0' allowfullscreen></iframe>
</div>The first {{ content }} prints out the url perfectly.
The second iframe shows the correct website but the first iframe is just empty...
I would really appreciate any help!
Comments
That's printing the entire
That's printing the entire node content as the iframe src. You just want the url from the link field. Take a look at https://drupal.stackexchange.com/questions/199262/how-to-get-the-valid-url-of-a-link-field-from-within-a-twig-template/199263
Fixed partly
It helped a little bit, but the problem is not solved yet.
I changed the code to the following:
If I inspect the ifram on the website now, it shows the follwing underlying code:
So it does the right How can I remove those?thing, but adds a <p> in the front and a
</p>in the back. How can I remove those?Thanks in advance
You shouldn't use the body
You shouldn't use the body field if all you want is a link. Use a proper link field instead.