seekrit squirrel

nerd central => coding => Topic started by: galumay on March 05, 2017, 09:27:24 AM

Title: Anchors & Links in SMF
Post by: galumay on March 05, 2017, 09:27:24 AM
I wanted to be able to link to one part of a thread from another on the forum, and also to link from another thread into a section of a post in a thread. It proved to be a bit more complicated than expected so I will document it here for future reference. Thanks to Arantor & Kindred on the SimpleMachines Forums Community for their help in resolving this.

So the easy bit first, to create an anchor the coding is, where title is the name of the anchor

Code: [Select]
[anchor=title]whatever text you want to use[/anchor]
Then if you are linking to the anchor from within the same page, then use the iurl code,

Code: [Select]
[iurl=#title]Text you want to display in link[/iurl]
If you want to create a link from another page or thread in the forum then you need to use this format, copy the URL of the message where the anchor resides and then delete the message number after the # (so for this message, http://www.galumay.com.au/forum/index.php?topic=53.msg157# ) and then add 'post_' and whatever the title of the anchor is.

Code: [Select]
[url=http://www.galumay.com.au/forum/index.php?topic=53.msg157#post_title]click here to view[/url]
For working examples of both, click click here (http://www.galumay.com.au/forum/index.php?topic=50.msg152#msg152)

Click on the link "Click here to view" on the DDR thread and it will take you to the anchor which is the DDR post in the linked thread, if you scroll back up to the top of the page you will see the links for all the anchors in the page using the coding for links within the post.