Anchor links

Throw your ideas for Druchii.net around in here...

Moderator: The Dread Knights

Post Reply
User avatar
Daeron
Malekith's Best Friend
Posts: 3973
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Anchor links

Post by Daeron »

Greetings,

I stumbled on this on the D.R.A.I.C.H topic, but it was impossible to make a table of contents using links to anchor points. I'm not sure if we need support to make named links (anchors) since every post already recieves one from the system. But it would be practical to support linking to them.

There is no coding, mod or extension needed for this.

This topic describes how to do achieve this, using native functionality:
https://www.phpbb.com/community/viewtopic.php?p=7216175

It would be nice to be able to refer to other posts on the same page without having to relead the topic and page.

Cheers,
Daeron
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
User avatar
Daeron
Malekith's Best Friend
Posts: 3973
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: Anchor links

Post by Daeron »

This functionality is now supported.

People can use the following code to create an anchor:

Code: Select all

[anchor]name_of_the_anchor[/anchor]


And then create a "goto" link to the anchor as such:

Code: Select all

[goto=name_of_the_anchor]Link to another point in the post.[/goto]


Note that the "#" sign is not required in the name. This is provided by the forum.

For example, you can jump back to the anchor code or the original request with this, without having to reload the page.
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
User avatar
Tarbo
Morathi's Best Friend
Morathi's Best Friend
Posts: 1203
Joined: Tue Oct 04, 2005 5:06 pm
Location: Flanders, Belgium

Re: Anchor links

Post by Tarbo »

Silly question: what happens when two posts on the same page view use the same anchor names? Is this changed behind the scenes to make them unique (but how would linking work)? Will they stay the same and let the browser sort it out?

I was thinking of using this for the SAU. Some of my posts can be large, and anchors could be useful to link directly to results at the bottom. And being the confused lazy git that I am, I was wondering whether I'd need to use different anchors for different posts.

Also: yay, anchors! :D
User avatar
Daeron
Malekith's Best Friend
Posts: 3973
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: Anchor links

Post by Daeron »

Interesting questions. There's nothing to prevent the same post, let alone page, to generate the same anchor. How this is treated, would then depend on the browser's behavior. You have to use a unique anchor if you want to be sure.

What exactly is it you want to do? To have a general link in the first post and have it automatically link to the latest results?
Or will you be posting a new link in the same or a new post every time?

In the former case, we'll have to add new functionality to the forum. I'm not sure how it can be done "the easy way" yet. For the latter, it might be interesting to use a lazy trick: just add a day+month code in front.
Like:

Code: Select all

[anchor]0924results[/anchor]

And then a goto can be:

Code: Select all

[goto=0924results]The latest results[/goto]


I could note that phpBB3 and this template we're using already generates a few interesting anchors:
- One per post, but the "id" of the post is only known after the message is posted. Still you can use it. For example, your post has id "874968". the anchor for it is "#p874968". And so I can link to it without needing to edit your post.
- A "top" anchor, to get back to the top of the page.
- An "unread" anchor, to get to the first unread post of the topic.

We could also code in a few extras should they be useful, such as:
  • "latest post"
  • Bottom of the page
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
User avatar
Tarbo
Morathi's Best Friend
Morathi's Best Friend
Posts: 1203
Joined: Tue Oct 04, 2005 5:06 pm
Location: Flanders, Belgium

Re: Anchor links

Post by Tarbo »

Oh no, nothing that serious or organised.

The posts are structured like this:

  • Story so far
  • Separator line
  • Game information at that time, such as current votes, players in the game, and so on

Because these story parts can span several screens, I feel a bit silly linking to the post as a whole when I'd like to highlight the game information, which appears at the very bottom.

Obvious workaround: put this information at the top instead of at the bottom, but I've put the story on top for eight years now, and it feels weird to do it differently. Also, having the story on top neatly cordons off the different parts of the game (dawn, morning, noon, evening, dusk, night), and people have to scroll up a lot less to see the important bits.

Other obvious workaround: split into separate posts. I just know I'll muck this up spectacularly at one time or another. Don't ask me how; I'll find a way. I always find a way.

I was going to do what you now suggested: simply use a suitable prefix, like #day-1-dusk or #evening-4-1, and so on. But I was thinking I could get away with just letting my text editor insert some automatic anchor. :P Instead I'll have to (gasp) think for a moment.

If you see rust and gears spraying around, that's my brain having at it. Just stay indoors for a bit.

Must not... overthink... solution...!
User avatar
Daeron
Malekith's Best Friend
Posts: 3973
Joined: Fri Oct 03, 2003 7:36 pm
Location: Belgium, Brussels
Contact:

Re: Anchor links

Post by Daeron »



If the goto and anchor are within the same post, I wouldn't mind developing code to make this possible, such that you can reference to anchor points within the same post. It's certainly worth increasing the comfort of users that have been with us for 8 years ;)

TO start
I love me a bowl of numbers to crunch for breakfast. If you need anything theoryhammered, I gladly take requests.

Furnace of Arcana, a warhammer blog with delusional grandeur.

"I move unseen. I hide in light and shadow. I move faster than a bird. No plate of armour ever stopped me. I strike recruits and veterans with equal ease. And all shiver at my coldest of whispers."
- The stiff breeze
Post Reply