sulu / sulu

Core framework that implements the functionality of the Sulu content management system
https://sulu.io
MIT License
1.15k stars 335 forks source link

Add possibility to remove a sulu-link if not exist #6956

Closed alexander-schranz closed 11 months ago

alexander-schranz commented 1 year ago

Problem description

If you have a sulu-link and the target page does not exist the whole tag is removed but the text stay as it is. This is expected behaviour when the sulu-link is used inside a text editor so nothing is removed from the text.

But when the sulu-link is used via the link content type it would be nice if there is a attribute to tell if the target link does not exist to remove also the text.

Proposed solution

Something like:

<sulu-link remove-if-not-exist="true" ... >

The service handling this is the HtmlMarkupParser and its child services. Which would needed to add the new support for this attribute.

mamazu commented 1 year ago

This is already happening: https://github.com/sulu/sulu/blob/829646662dc20e45fc02749092c44ad4102e052c/src/Sulu/Bundle/MarkupBundle/Markup/LinkTag.php#L105C20-L105C20

And any link that can not be found will be removed from the resulting HTML.

alexander-schranz commented 1 year ago

Yeah but the content is still outputted, in this case whole tag with content should be removed.

mamazu commented 1 year ago

No problem. :D