Simple Machines Community Forum

General Community => Scripting Help => Topic started by: galumay on March 02, 2017, 02:48:58 AM

Title: Scripting for anchors help
Post by: galumay on March 02, 2017, 02:48:58 AM
Hi guys,

I want to be able to ebed 'anchors' within my posts so that I can link to them from other threads. I have used forums that have an anchor button for each post, which would be sufficient for my purposes - or i could insert an anchor at the specific text within a post that i wanted to link to.

I have played with the bbc code,

[anchor=A]Text[/anchor]

But there seems to be no way to link from a different thread in the forum,

I have tried doing it in HTML, which I know how to do, but HTML code is so locked down in SMF that the anchor coding is not allowed so I dont think that will work.

Is there any way to do this in SMF or should I look to using a different forum software?
Title: Re: Scripting for anchors help
Post by: Arantor on March 02, 2017, 02:54:03 AM
There is but it is a touch convoluted because linking to the middle of a post in another thread is not a usual use case.

Anyway. The post title for every post is a link to that post. E.g. your post is http://www.simplemachines.org/community/index.php?topic=552511.msg3916833#msg3916833

Get the link for your post, then change the bit after the # to what you define in your anchor and put it all in a URL bbcode. The rest of the stuff ensures SMF loads the right page of the right topic.
Title: Re: Scripting for anchors help
Post by: galumay on March 02, 2017, 04:59:32 AM
Quote from: Arantor on March 02, 2017, 02:54:03 AM
There is but it is a touch convoluted because linking to the middle of a post in another thread is not a usual use case.

Anyway. The post title for every post is a link to that post. E.g. your post is http://www.simplemachines.org/community/index.php?topic=552511.msg3916833#msg3916833

Get the link for your post, then change the bit after the # to what you define in your anchor and put it all in a URL bbcode. The rest of the stuff ensures SMF loads the right page of the right topic.

Thanks for the prompt reply Arantor. I suspect its the other way round with SMF! Its not usual to link to the middle of a post in another thread because its a touch convoluted! Other forum software makes it very straight forward and hence it gets used to cross reference information.

The SMF implementation you describe is next to useless - I got that working but assumed it was broken because it simply opens to the top of the relevant page - where as the information I want to be able to link to will typically be buried way down the page.

I might have to look at migrating the forum as its become an increasingly required feature as the forum grows.
Title: Re: Scripting for anchors help
Post by: Arantor on March 02, 2017, 06:31:41 AM
Can I see an example? Maybe I misconstructed the link.
Title: Re: Scripting for anchors help
Post by: galumay on March 02, 2017, 06:59:23 AM
Quote from: Arantor on March 02, 2017, 06:31:41 AM
Can I see an example? Maybe I misconstructed the link.

Arantor, I dont think you misconstructed the link, its exactly what I had tried, but it takes you to the top of the page within which the anchor is set. If its a page with a number of replies the anchor may well be towards the bottom of the page and not at all obvious from the link opening at the top of the page.

Title: Re: Scripting for anchors help
Post by: Arantor on March 02, 2017, 07:03:06 AM
Then I did misconstruct the link because as given it should do EXACTLY what you want.

Which is why I want to see examples.
Title: Re: Scripting for anchors help
Post by: Illori on March 02, 2017, 07:31:08 AM
does http://www.simplemachines.org/community/index.php?topic=224166#post_db_query do what you are expecting?
Title: Re: Scripting for anchors help
Post by: Kindred on March 02, 2017, 09:41:38 AM
What she is actually asking is:   Does the link that she provided in the post, above, bring you to the middle of the post/thread with the
$smcFunc['db_query'] (identifier, query, values, connection)
line at the top of the screen?

If so, then you did somethign incorrectly when following Arantor's suggestion, since that link uses the exact method that Arantor describes.
Title: Re: Scripting for anchors help
Post by: Arantor on March 02, 2017, 10:50:55 AM
Except for the part where it has "post_" at the front which I think I omitted because I think the anchor tag puts that in, and that I forgot about it. Which is why I wanted examples I could see.
Title: Re: Scripting for anchors help
Post by: Kindred on March 02, 2017, 10:55:55 AM
whoops...I missed that too....  yeah.


[anchor=db_query]$smcFunc['db_query'] (identifier, query, values, connection)[/anchor]


creates an anchor using
#post_db_query
Title: Re: Scripting for anchors help
Post by: galumay on March 03, 2017, 06:19:58 AM
Ok, I cant see why the examples work and mine doesnt, so if you go to,

http://www.galumay.com.au/forum/index.php?topic=50.msg152#msg152

You will see a link that will go to the top of the page, not to the anchor.

Interestingly I added links to anchors at the top of the page using [iul] and they work fine within the page!

I am clearly missing something really obvious, so put me out of my misery and tell me where I am going wrong!!
Title: Re: Scripting for anchors help
Post by: Arantor on March 03, 2017, 06:33:45 AM
The link you provided works exactly as expected. The page is too short, since there's only one post. The browser has scrolled it down as far as possible.

I don't see any anchor tag in your post though for the purposes of linking to #post_DDR
Title: Re: Scripting for anchors help
Post by: galumay on March 03, 2017, 08:13:41 PM
Quote from: Arantor on March 03, 2017, 06:33:45 AM
The link you provided works exactly as expected. The page is too short, since there's only one post. The browser has scrolled it down as far as possible.

I don't see any anchor tag in your post though for the purposes of linking to #post_DDR

Huh???!! No it doesnt, when you click on the link it just opens the other thread, at the very top of the page. According to what you and others describe it should open with the anchor at the top of the browser window. The anchor is well down the page and I have to scroll about half way down to get to the anchor.

The anchor is at the section "Share-DDR" it is coded into the heading,

[b][Anchor=DDR]Share-DDR[/Anchor][/b]

As I said you can see how it works fine if its within the same page, the DDR link at the top of the post will move the curser down to the DDR anchor. Just doesnt seem to function linking from another thread.
Title: Re: Scripting for anchors help
Post by: Kindred on March 03, 2017, 08:58:12 PM
http://www.galumay.com.au/forum/index.php?topic=52.msg104#post_DDR

This works just fine for me...
Title: Re: Scripting for anchors help
Post by: Arantor on March 04, 2017, 02:43:39 AM
Quote from: galumay link=topic=552511.msg3917147#msg3917147

Huh???!! No it doesnt, when you click on the link it just opens the other thread, at the very top of the page.

See attached where it opened it at the bottom of the window as I described, from the link you gave me.

Quote
According to what you and others describe it should open with the anchor at the top of the browser window. The anchor is well down the page and I have to scroll about half way down to get to the anchor.

The anchor is at the section "Share-DDR" it is coded into the heading,

[b][Anchor=DDR]Share-DDR[/Anchor][/b]


The part after the # should be #post_DDR not #DDR because I forgot that it needed that 'post_' prefix. The link as constructed by Kindred is what I was trying to do but I haven't done it in a long time, and I'd forgotten, whilst trying to be helpful in between doing things at work - and apparently all I get for trying to be helpful is a thinly veiled accusation of being a liar.
Title: Re: Scripting for anchors help
Post by: galumay on March 04, 2017, 06:43:37 PM
QuoteThe part after the # should be #post_DDR not #DDR because I forgot that it needed that 'post_' prefix. The link as constructed by Kindred is what I was trying to do but I haven't done it in a long time, and I'd forgotten, whilst trying to be helpful in between doing things at work - and apparently all I get for trying to be helpful is a thinly veiled accusation of being a liar.

Sorry, I didnt realise you were so precious. The instructions you gave me didnt work - because they were incorrect - and I missed the fact that Kindred had added the correction. I wasnt accusing you of lying - i was factually reporting that it simply didnt work the way you described - which of course was because the 'post_' prefix was missing.

Despite your over-reaction I can assure you I greatly appreciate your help and pesistence in resolving this issue for me with Kindred's help.