News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

"Link To This Topic"

Started by destalk, April 22, 2007, 12:52:21 AM

Previous topic - Next topic

destalk

I thought that it might be good if at the bottom of each topic there was some "Link To This Thread" text. A kind of permalink function I suppose.

E.G. To link to this topic from your web site, please copy the code below and paste into your web page
<a href="http://www.simplemachines.org/community/index.php?topic=166654.0">Link To This Topic </a>


Sure the user could simply copy and paste the URL from their title bar. But often they have arrived at the thread via one of the .msg post urls and that means that visitors arriving at the topic from an external link would arrive in the middle of the thread. This mod would encourage a more systematic linking process.

Anyone?

青山 素子

The topic title in the navigation bar has a direct link to the first page of the thread already.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


destalk

Indeed. But only someone familiar with SMF would know this. Most people would, otherwise, simply copy and paste whatever was in the address bar.

The idea is that we are making it easy for casual visitors and less-technical users to copy and paste the correct URL. In fact, it goes a step further in actually encouraging people to link to a useful thread.

I'm also thinking of situations where a post might be deleted and so on. The permalink idea being that inbound links always go to the 'permanent' URL.

I just thought that it would be a useful mod if it wasn't too hard to code (not that I know anything about that, unfortunately).

青山 素子

It is really just a quick theme change. I mean, you could make it a mod, but there isn't much there.

Try a link like this:

echo '<a href="', $_SERVER["REQUEST_URI"], '">', $context['page_title'], '</a>';
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


destalk

Thanks Motoko-chan

But just to show how thick I really am. Are you saying that I should put this somewhere in the display index?

Thanks again.

青山 素子

The template that shows the posts is "Display.template.php". You will need to find an appropriate place in there to place that snippet. It will depend on the theme and how you want it to display on the page.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


destalk

Thanks.

Unfortunately that does the exact thing that I didn't want it to do. :) It creates a link from the URL where the user happens to be. So if they are on http://www.simplemachines.org/community/index.php?topic=166654.msg1070790#msg1070790, then it creates a link to http://www.simplemachines.org/community/index.php?topic=166654.msg1070790#msg1070790

Whereas I wanted it to create a link to the top of the page here; http://www.simplemachines.org/community/index.php?topic=166654.0

But also, rather than just a simple link. I wanted it to actually display the 'raw' URL, rather than an active link. This would allow the user to copy and paste that into their web page.

<a href="http://www.simplemachines.org/community/index.php?topic=166654.0">Link To This Topic </a>

Advertisement: