<p><a href="https://craftcms.stackexchange.com/a/2504/177">Instead of a shortcode</a>, you could also <a href="http://twig.sensiolabs.org/doc/advanced.html#filters" rel="nofollow noreferrer">write a filter</a> which finds all links, and if they are "local", checks their status by slug, and possibly removes them.</p>

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

CC BY-SA 3.0
2014-09-12T14:40:37.707Z
Yeah that sounds closer to what I want. Time to learn how to write plugins, I guess!
hamishtaplin
CC BY-SA 3.0
2014-09-12T20:31:58.150Z
Good call - this would be much less work than my solution.
shanecavaliere
CC BY-SA 3.0
2014-09-12T09:03:23.503Z
2014-09-12T09:03:23.503Z
2017-04-13T12:51:00.303Z
Victor
<p>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: <a href="https://github.com/samhernandez/craftcms-shortcodes" rel="nofollow">https://github.com/samhernandez/craftcms-shortcodes</a>. 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.</p>

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

CC BY-SA 3.0
2014-09-12T07:46:20.030Z
Yeah this sounds like a lot of work. Might have to reconsider. Thanks!
hamishtaplin
CC BY-SA 3.0
2014-09-12T05:12:37.483Z
2014-09-12T07:47:12.117Z
2014-09-12T07:47:12.117Z
shanecavaliere
<p>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.</p>

<p>Is this currently possible?</p>

<entry><richtext>
Status of links to entries in body copy
# Status of links to entries in body copy

(Asked by: username_0 on 2014-09-11)

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?

**Tags:** entry, richtext

---

## 2 answers

### Answer by username_1 on 2014-09-12. Score: 2

[Instead of a shortcode](https://craftcms.stackexchange.com/a/2504/177), you could also [write a filter](http://twig.sensiolabs.org/doc/advanced.html#filters) 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.

> **Comments:**
> **username_0**: Yeah that sounds closer to what I want. Time to learn how to write plugins, I guess!  
> **username_2**: Good call - this would be much less work than my solution.  

---

### Answer by username_2 on 2014-09-12. Score: 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.

> **Comments:**
> **username_0**: Yeah this sounds like a lot of work. Might have to reconsider. Thanks!  

---

