Advertisement:

Author Topic: Scripting for anchors help  (Read 1788 times)

Offline galumay

  • Newbie
  • *
  • Posts: 7
Scripting for anchors help
« 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,

Code: [Select]
[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?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 66,507
    • Arantor on GitHub
Re: Scripting for anchors help
« Reply #1 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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Offline galumay

  • Newbie
  • *
  • Posts: 7
Re: Scripting for anchors help
« Reply #2 on: March 02, 2017, 04:59:32 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.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 66,507
    • Arantor on GitHub
Re: Scripting for anchors help
« Reply #3 on: March 02, 2017, 06:31:41 AM »
Can I see an example? Maybe I misconstructed the link.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Offline galumay

  • Newbie
  • *
  • Posts: 7
Re: Scripting for anchors help
« Reply #4 on: March 02, 2017, 06:59:23 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.


Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 66,507
    • Arantor on GitHub
Re: Scripting for anchors help
« Reply #5 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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Offline Illori

  • Project Manager
  • SMF Master
  • *
  • Posts: 45,883
Re: Scripting for anchors help
« Reply #6 on: March 02, 2017, 07:31:08 AM »

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 53,863
  • Gender: Male
    • Kindred-999 on GitHub
Re: Scripting for anchors help
« Reply #7 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.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 66,507
    • Arantor on GitHub
Re: Scripting for anchors help
« Reply #8 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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 53,863
  • Gender: Male
    • Kindred-999 on GitHub
Re: Scripting for anchors help
« Reply #9 on: March 02, 2017, 10:55:55 AM »
whoops...I missed that too....  yeah.

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

creates an anchor using
#post_db_query
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline galumay

  • Newbie
  • *
  • Posts: 7
Re: Scripting for anchors help
« Reply #10 on: March 03, 2017, 06:19:58 AM »
Ok, I cant see why the examples work and mine doesnt, so if you go to,

hxxp:www.galumay.com.au/forum/index.php?topic=50.msg152#msg152 [nonactive]

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!!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 66,507
    • Arantor on GitHub
Re: Scripting for anchors help
« Reply #11 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
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Offline galumay

  • Newbie
  • *
  • Posts: 7
Re: Scripting for anchors help
« Reply #12 on: March 03, 2017, 08:13:41 PM »
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,

Code: [Select]
[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.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 53,863
  • Gender: Male
    • Kindred-999 on GitHub
Re: Scripting for anchors help
« Reply #13 on: March 03, 2017, 08:58:12 PM »
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 66,507
    • Arantor on GitHub
Re: Scripting for anchors help
« Reply #14 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,

Code: [Select]
[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.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

Offline galumay

  • Newbie
  • *
  • Posts: 7
Re: Scripting for anchors help
« Reply #15 on: March 04, 2017, 06:43:37 PM »
Quote
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.

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.