XF 2.3 Auto-Linking URLs

mjda

Well-known member
I'm using the editor in one of my add-ons but when someone types a URL into the editor, it doesn't automatically convert to a link. Also, links don't unfurl. All other BBCode seems to work just fine. I'm assuming there is something specific that needs to be done to make this work, but I can't figure it out. Hoping one of you can point me in the right direction.
 
Solution
It'll actually most likely be similar to the thread linked earlier, you need to run the message through the message preparer service to process things like autolinking, mentions, markdown (if enabled), etc:

I went through the same hurdles I believe when making my Blogs addon, https://xenforo.com/community/threads/content-unfurling.224901/#post-1704227.

Pretty sure it just didn't want to work on my local install (not sure if that's where you are testing) and also the links all had to have proper metadata set.

Unfurls are working just fine in the threads. I'm trying to get some custom content, by the add-on, to allow for unfurling URLs, or at least auto-linking of URLs. I thought maybe simply using bb_code() would do it, but that doesn't work.
 
That's also how I'm achieving it in my blog posts

Code:
{{ bb_code($blogPost.blog_post_content, 'taylorj_blogs_blog_post',
                                        $blogPost) }}
It's been a long while since I ran into this, but maybe you need to make sure you have a proper content_type setup for whatever it is you're showing?
 
It's been a long while since I ran into this, but maybe you need to make sure you have a proper content_type setup for whatever it is you're showing?

Yeah, I set that up properly (I think). I've got an entity assigned, if that's what you mean? I had to have that for the sitemap and search handlers to work. If there's something other than that for content types, though, that could be the problem.

I was thinking there might be something else I needed to do in my entity, or controller, similar to what I had to do to get it so that attachments would show up in the content (instead of just "View attachment X").
 
Here's what I'm using to display the content:

Code:
{{ bb_code($siteData.site_data, 'mjda_site_data', $siteData) }}

As I said, all BBCode currently works. If I add [url=URL]text[/url] that will work too. But if I just type the URL, it won't convert to a link. Also, in this content, nothing will unfurl.
 
I just noticed that if you type a URL into your "About" section in your profile that also doesn't auto-convert into a link, so there's definitely something else going on to make it so it automatically converts them in posts/direct messages. Just gotta figure out what that "something else" is so I can implement it into my content too.
 
After some more digging and you making something pop into my head when bringing up how it doesn't work on user profiles, I believe it may have to do with your content_type needing an embed_resolver_class.
 
After some more digging and you making something pop into my head when bringing up how it doesn't work on user profiles, I believe it may have to do with your content_type needing an embed_resolver_class.

Ok, thank you! I'll go give that a shot and see what happens.
 
It'll actually most likely be similar to the thread linked earlier, you need to run the message through the message preparer service to process things like autolinking, mentions, markdown (if enabled), etc:

 
Solution
Back
Top Bottom