MyBB Community Forums

Full Version: Developing a code that shortens links
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I want to develop a code that would shorten links to threads and stuff. i.e. something like [threadx]text[/thread] would link to the thread with thread id x. So,

[thread74892]Blah blah blah[/thread]

would turn into

Blah blah blah.

Is there any way to code this? I tried saying [threadx]??[/thread] should link to but it'll only produce a link for x, not for numbers.

Is there a way of coding this without having to add 10000 new codes?

(My apologies if this has been posted before.)
Title: Short links

Regular Expression:
\[thread=([0-9]+)\]([a-z0-9_\- ,.+]+)\[/thread\]

<a href="http://localhost/showthread.php?tid=$1" title="$2">$2</a>

How would this work if you're using Google SEO URLs set up as "showthread.php?123-Name-of-Thread"? Or does this only work with the default MyBB URL scheme? This would be a very useful item to use for my board.
I think the standard MyBB links redirect to the Google SEO / MyBB SEO links when visited. Not 100% sure on that though.
It should redirect if you enable so in the plugin settings. If you want it for the sake of beauty then you will need a plugin.