MyBB Community Forums
Developing a code that shortens links - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Resources (https://community.mybb.com/forum-8.html)
+--- Forum: MyCodes (https://community.mybb.com/forum-117.html)
+--- Thread: Developing a code that shortens links (/thread-126944.html)



Developing a code that shortens links - Lugia - 2012-09-30

Hey,

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 http://community.mybb.com/thread-x.html 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.)


RE: Developing a code that shortens links - Omar G. - 2012-10-01

Title: Short links

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

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

Test:
[thread=123]title[/thread]



RE: Developing a code that shortens links - Glitch - 2012-10-07

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.


RE: Developing a code that shortens links - Krytic - 2012-10-07

I think the standard MyBB links redirect to the Google SEO / MyBB SEO links when visited. Not 100% sure on that though.


RE: Developing a code that shortens links - Omar G. - 2012-10-08

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.