So since I hate it when someone like me glibly says "write a callback" I thought I should rough something out as an example. Now PHP is not my language of choice and I don't use it very often so don't take this as the "right" way to do it!
Obviously rename things as required. So I'll create the callback first. For this example I'm going to create a file in my XF install:
src/addons/Generic/MediaSites/MsnMedia.php
and populate it thus:
PHP:
<?php
namespace Generic\MediaSites;
class MsnMedia
{
public static function htmlCallback($mediaKey, array $site, $siteId)
{
$params = ['siteId' => $siteId ];
$urlInfo = explode('/', $mediaKey);
$params['lang'] = rawurlencode($urlInfo[0]);
$params['category'] = rawurlencode($urlInfo[1]);
$params['section'] = rawurlencode($urlInfo[2]);
$params['slug'] = rawurlencode($urlInfo[3]);
$params['id'] = rawurlencode($urlInfo[4]);
$params['title'] = ucfirst(str_replace('-', ' ', $params['slug']));
$params['raw'] = $mediaKey;
return \XF::app()->templater()->renderTemplate('public:_media_site_embed_MSN', $params);
}
}
So I thought it worth breaking down the 'id' (
$mediaKey
) the function received, but I guess you wouldn't have to - although you might want to be a bit careful about what you echo back to your site for inclusion in pages! You could obviously do a bit more robust validation here, for example making sure things matched patterns to prevent any potential abuse.
Anyhow back to the admin UI now and create a new BB code media site. I shall call give it a
Media site ID of
MSN. Note that the ID will determine what the template is named, note the last line of the PHP
return \XF::app()->templater()->renderTemplate('public:_media_site_embed_MSN', $params);
, the
MSN
bit of that comes from the
Media site ID.
I'll set the
Match URLs to
#https://www\.msn\.com/(?P<id>[a-z0-9_\-\/]+)#i
and fill in the
Embed Template (note that under the
Embed Template title is the template name - _media_site_embed_MSN) thus:
HTML:
<a href="https://www.msn.com/{$lang}/{$category}/{$section}/{$slug}/{$id}">MSN: {$title}</a>
In the Advanced Options section I am going to enable
Regular expression matching and then for the
Embed HTML callback I will set the first box to
Generic\MediaSites\MsnMedia
and the second box to
htmlCallback
That should be that and should render the link out as "MSN: The slug title here". You can tweak the template as desired to make it look how you want.
Anyhow hopefully that might be of some use to get started on this "work around".
That all said I think a simple "don't unfurl" URL list for XenForo would be an awesome addition and very welcome.