XF 2.2 Edit BB code media site with different URL endings before {$id}

Joao Prates

Active member
Hi,

I'm trying to create a custom BB code for Tidal, and I already got it working for tracks using this match url https://tidal.com/browse/track/{$id:alphanum} and using this code:

HTML:
<div class="bbMediaWrapper" data-media-site-id="{$siteId}" data-media-key="{$id}">
    <div class="bbMediaWrapper-inner bbMediaWrapper-inner--232px">
        <iframe src="https://embed.tidal.com/tracks/{$id}?layout=gridify"
                frameborder="1"
                style="width: 500px; height: 232px; min-height: 100%; margin: 0 auto;">
        </iframe>
    </div>
</div>

The issue is I can't find a way to make it work for albums as well, since the match url would be https://tidal.com/browse/album/{$id:alphanum} and I can't find a way to make the distinction between them since the id part only takes the number at the end of the url.

I already tried a more general match url with https://tidal.com/browse/{$id:alphanum} but the {$id} only gets "track" or "album" and ignores the slash and number at the end, i.e. it stops assigning the var when it finds the slash.

I don't know enough about xenforo scripting, but I believe this should be possible.

This was my last try, which obviously did not work, but you get the idea of what I'm trying from it, having the match url as https://tidal.com/browse/{$id:alphanum}

HTML:
<div class="bbMediaWrapper" data-media-site-id="{$siteId}" data-media-key="{$id}">
    <div class="bbMediaWrapper-inner bbMediaWrapper-inner--232px">
        <iframe
            base_url="https://embed.tidal.com/"
            <?php ({$id} | regex_search("^track")) ? src=base_url.concat("tracks/{$id}?layout=gridify") : ; ?>
            <?php ({$id} | regex_search("^album")) ? src=base_url.concat("albums/{$id}?layout=gridify") : ; ?>
            <?php echo (src) ?>
            frameborder="0"
            style="width: 500px; height: 232px; min-height: 100%; margin: 0 auto;">
        </iframe>
    </div>
</div>

Any help would be greatly appreciated.

Cheers,
-jprates
 
PHP was just one of any option I could think of using, I really don't have a preference for such a small task.

Meaning that if there is a scripting method that works inside the template, I can try it - is there a way to achieve this inside the template without going for callbacks?

p.s. - Anyway I also don't mind having to look at the advanced options and callback usage if really needed, just seems an overkill, but if that's the only way to go, then be it.
 
Back
Top Bottom