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

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.

| improve this answer | |
  • Yeah this sounds like a lot of work. Might have to reconsider. Thanks! – hamishtaplin Sep 12 '14 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.

| improve this answer | |
  • Yeah that sounds closer to what I want. Time to learn how to write plugins, I guess! – hamishtaplin Sep 12 '14 at 14:40
  • Good call - this would be much less work than my solution. – shanecavaliere Sep 12 '14 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.