2

Is it possible to check the status of entries linked to in content from the Rich Text field? For example, the user might create a link in a paragraph to an entry that is in draft status. I would like to only display an actual link in the front end if this entry is then published.

Is this currently possible?

2 Answers 2

2

I don't think it's possible out-of-the-box, but you might be able to get something like that working with a shortcode approach. You could make a custom shortcode with a link parameter, and in the function for that shortcode, look up that link parameter's corresponding entry and find out its status. Then the shortcode could output a link if the entry was published, and just the original text otherwise. Here's a plugin that lets you add shortcodes: https://github.com/samhernandez/craftcms-shortcodes. If you wanted to get really fancy, you could even make a new redactor (the WYSIWYG editor Craft uses) button that inserts the shortcode instead of the normal anchor HTML.

This approach would probably take a bit of work, though. I'd be interested to see if anyone else has a better solution.

1
  • Yeah this sounds like a lot of work. Might have to reconsider. Thanks! Commented Sep 12, 2014 at 7:46
2

Instead of a shortcode, you could also write a filter which finds all links, and if they are "local", checks their status by slug, and possibly removes them.

The advantage is that the end-user doesn't have to worry about shortcodes or special redactor-buttons.

2
  • Yeah that sounds closer to what I want. Time to learn how to write plugins, I guess! Commented Sep 12, 2014 at 14:40
  • Good call - this would be much less work than my solution. Commented Sep 12, 2014 at 20:31

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.