Splitting a topic breaks quote links

Started by Kolya, January 16, 2021, 01:26:23 PM

Previous topic - Next topic

Kolya

SMF 2.0.17

I never noticed this before, probably because I rarely split topics. But apparently it breaks all quote links in the new split-off topic.
They still point to the old topic but cannot find the correct message there of course.

So is this normal? Is there a fix or a mod that fixes it?

Aleksi "Lex" Kilpinen

Well, the quote format in 2.0 is originally designed to point to a topic first, and a unique post second.
That can cause issues in situations like that. 2.1 fixed that, and removed the topic pointer as unnecessary.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Kolya

I see. Since 2.1 is still RC I'm not willing to install it. But if the topic pointer is really just superfluous I guess I could remove it myself. I'll have to take a look at how 2.1 did it.
Thank you.

Aleksi "Lex" Kilpinen

#3
2.0 format:


[quote author=Kolya link=topic=576366.msg4078560#msg4078560 date=1610823674]
I see. Since 2.1 is still RC I'm not willing to install it. But if the topic pointer is really just superfluous I guess I could remove it myself. I'll have to take a look at how 2.1 did it.
Thank you.
[/quote]


2.1 format:


[quote author=Kolya link=msg=4078560 date=1610823674]
I see. Since 2.1 is still RC I'm not willing to install it. But if the topic pointer is really just superfluous I guess I could remove it myself. I'll have to take a look at how 2.1 did it.
Thank you.
[/quote]


Obviously, doesn't work here - we are still on 2.0
Still, even on 2.0 you can link to a specific post directly with https://www.simplemachines.org/community/index.php?msg=4078560
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Illori

even if you upgrade to 2.1, it will not fix the existing links for quotes that already exist, just those made in the future.

Kolya

Thanks Illori, I figured as much since the link is written into the posts.

I know where it's matched with a regex in Subs.php, and I just found where it is generated in Post.php.
Comparing it to SMF 2.1 now. Doesn't look too difficult. (His last words)

The whole thing is especially important to me, since I created a Reply-To-Post function, which is basically a quote without quote text, just the link back. Hence it uses the quote code.

Kolya

I made the changes without problems, however I'm not absolutely happy with the result.

Previously a quote link looked like this: /index.php?topic=11449.msg137830#msg137830
Now it looks like this: /index.php?msg=137622

While we gained the ability to link to posts regardless of topic, we lost the ability to just scroll up to the message when it's on the same page.
A page reload is now inevitable, since the new URL never matches the current topic URL.

Looks like the topic in the URL wasn't really unnecessary. The hashtag anchor suggests back-scrolling was achieved intentionally in the original code.

Aleksi "Lex" Kilpinen

Actually no, the ?msg=*** link should get you to the exact message, just as the old link did.
You can try it here, following this link https://www.simplemachines.org/community/index.php?msg=4078560 you should get directly to that post.

EDIT: Oh, I guess I misread you a bit - But I'm not sure if clicking on a quote link you would ever avoid a page load though.
The hashtag was there for initial page load, not for avoiding the page load as far as I know.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Kolya

Yes, the browser eventually gets to the correct URL after following the redirect. But that still forces a page reload.

These links end up in the same place, but the first just scrolls back up, while the second page reloads:
1. https://www.simplemachines.org/community/index.php?topic=576366.msg4078558#msg4078558
2. https://www.simplemachines.org/community/index.php?msg=4078558

Example doesn't work here, because target="_blank" is set on both links...

A better solution would be to figure out the new full URL in PHP and then linked to that, instead of sending the browser to a redirect.

Aleksi "Lex" Kilpinen

No, the first one doesn't scroll back either - not by default, or at least I haven't ever seen that.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Kolya

True, the example doesn't work here, because target="_blank" is set on both links. Otherwise the first link would just scroll up without a page reload.

You can click on quote links here to see what I mean: https://www.systemshock.org/index.php?topic=11449.0

Aleksi "Lex" Kilpinen

Even without that, it does a page load first, and only then gets you to the anchor. Because the quote or the link doesn't hold the information on if the post is actually on the same page at all.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Kolya

If the linked URL is the same as the current URL, only with a hashtag anchor added, the browser merely scrolls to that place.
You just broke that indended function here by adding target="_blank" to all links.
I added an example in my previous post.

Aleksi "Lex" Kilpinen

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Aleksi "Lex" Kilpinen

Quote from: Kolya on January 16, 2021, 05:32:20 PM
If the linked URL is the same as the current URL, only with a hashtag anchor added, the browser merely scrolls to that place.
You merely broke that indended function here by adding target="_blank" to all links.
I added an example in my previous post.
Nope, I tried before I posted. I actually tried it on 2.1 as well, and even there it does a page load to determine what page the post is on.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Kolya

Quote from: Aleksi "Lex" Kilpinen on January 16, 2021, 05:32:40 PM
Yeah, that's not default SMF behaviour.

Someone clearly intended it to work that way. There is no other reason to attach the hashtag anchor. And it would work here as well, if target="_blank" was not set on these links.

Anyway, I don't mean to be accusatory or anything. I merely find that the new solution has drawbacks for me.

Aleksi "Lex" Kilpinen

The anchor is there so that you can link to a specific post, and get to the post directly when you follow the link.
Both of your example links use the anchor to find it after the page load, the link format doesn't matter - they both lead to to the same URL including the anchor.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Kolya

I created a test topic to show the difference of the old and new quote links: https://www.systemshock.org/index.php?topic=11558

The first quote links to: https://www.systemshock.org/index.php?msg=137874
The second links to: https://www.systemshock.org/index.php?topic=11558.msg137874#msg137874

The first link is a redirect and forces a page reload.
That second link is the same URL you are on when viewing the topic, only with an anchor added. Hence it scrolls back.

Oh well, I guess it's just my bad luck that this apparently undocumented feature doesn't work anymore in 2.1

Aleksi "Lex" Kilpinen

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Kolya

A link is a link. Why would it not work the same way here if the target="_blank" was removed? This is default browser behavior*. There is no scripting involved.

* https://css-tricks.com/hash-tag-links-padding/

Advertisement: