How to create URL for latest post in topic?

Discussions about the forum and contents
Post Reply
User avatar
Topic Author
digarei
Posts: 888
Joined: Sat Jul 05, 2014 1:41 am
Location: Sacramento
Contact:

How to create URL for latest post in topic?

Post by digarei » Thu Feb 06, 2020 11:58 pm

. . .
How do I create a link that will highlight the last post in a specific thread?


Examples

This will set view to the top of the thread, displaying the first post:

Code: Select all

https://www.bogleheads.org/forum/viewtopic.php?f=9&t=161311

This one will set view to the top of page 3, starting at post 100

Code: Select all

https://www.bogleheads.org/forum/viewtopic.php?f=9&t=161311&start=100 

I want to jump to the final page, the latest post within the topic/thread.



Edited 2/7/2020 to clarify issue
. . .
Last edited by digarei on Fri Feb 07, 2020 7:32 pm, edited 2 times in total.
Connect with Bogleheads in Northern California! Click the link under my user info/avatar.

GrowthSeeker
Posts: 860
Joined: Tue May 15, 2018 10:14 pm

Re: How to create a URL for last post in topic?

Post by GrowthSeeker » Fri Feb 07, 2020 12:51 am

Good question. I'm not a guru, but you could start by web scraping the first page to see how many posts there are. Then append "&start=N" where "N" is that number rounded down to the nearest multiple of 50. That gets you to the top of the last page.
I checked several pages, and the next step is to append "#pM" where M is a 7 digit number, but I can't quite figure that one out. Maybe easier to loop through tags that match the title of the page.
There seems to be a div tag and also an <a href="..." tag which each include that #pM code where M is a 7 digit number. If you could capture that and append it to the URL, you'd be in business.

But you probably already figured that much out. I don't know if there is a keyword, such as "#unread" which connotes the last post.
Just because you're paranoid doesn't mean they're NOT out to get you.

sycamore
Posts: 729
Joined: Tue May 08, 2018 12:06 pm

Re: How to create a URL for last post in topic?

Post by sycamore » Fri Feb 07, 2020 7:14 am

It doesn't appear to be possible, at least based on this posting from 2016 from the phpBB forum (as you may know, bogleheads.org is powered by phpBB):

How to link to the last post of a topic (that still works after new posts are made)

That would be a nice feature, though.

rkhusky
Posts: 9522
Joined: Thu Aug 18, 2011 8:09 pm

Re: How to create a URL for last post in topic?

Post by rkhusky » Fri Feb 07, 2020 8:28 am

The page at https://www.bogleheads.org has links to the last post in each thread.

User avatar
prudent
Moderator
Posts: 7507
Joined: Fri May 20, 2011 2:50 pm

Re: How to create a URL for last post in topic?

Post by prudent » Fri Feb 07, 2020 8:58 am

rkhusky wrote:
Fri Feb 07, 2020 8:28 am
The page at https://www.bogleheads.org has links to the last post in each thread.
It actually links to the first unread post, or if there are no unread posts it will go to the first post on the last page of the thread.

User avatar
Peculiar_Investor
Posts: 1577
Joined: Thu Oct 20, 2011 12:23 am
Location: Staying home - Calgary, AB
Contact:

Re: How to create a URL for last post in topic?

Post by Peculiar_Investor » Fri Feb 07, 2020 9:04 am

digarei wrote:
Thu Feb 06, 2020 11:58 pm
. . .
How do I create a link that will highlight the last post in a specific thread topic?
I'm curious to the use case, could you expand a bit further on what you are trying to accomplish?

I'm going to take a bit of a guess and explain a specific use case, if you are viewing a forum index, it is possible to jump to the last post. It is dependent on the device:
  • on a desktop - look at the Last post column, beside the member name is an diagonal arrow pointing to the right. Hover over it and the tooltip says "Go to last post".
  • on a mobile device, the date/time field is a clickable link to the last post.
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams

User avatar
Topic Author
digarei
Posts: 888
Joined: Sat Jul 05, 2014 1:41 am
Location: Sacramento
Contact:

Re: How to create a URL for last post in topic?

Post by digarei » Fri Feb 07, 2020 10:43 am

Peculiar_Investor wrote:
Fri Feb 07, 2020 9:04 am
digarei wrote:
Thu Feb 06, 2020 11:58 pm
. . .
How do I create a link that will highlight the last post in a specific thread topic?
I'm curious to the use case, could you expand a bit further on what you are trying to accomplish?

I'm going to take a bit of a guess and explain a specific use case, if you are viewing a forum index, it is possible to jump to the last post. It is dependent on the device:
  • on a desktop - look at the Last post column, beside the member name is an diagonal arrow pointing to the right. Hover over it and the tooltip says "Go to last post".
  • on a mobile device, the date/time field is a clickable link to the last post.
I use the first post of a local chapters master thread to provide information about our next chapter meeting. The URL used to reference this page is simply

Code: Select all

https://www.bogleheads.org/forum/viewtopic.php?f=9&t=161311

A few local chapters do as I do: they use the first post to update upcoming meetings, so I can likewise create a link referencing only the topic. When clicked, the URL will display the first post in that topic.

Other chapters advertise their upcoming meetings by creating a new post, which naturally falls to the bottom, chronologically. It’s the latest post that I wish to target, regardless of whether it has already been read by the user or others.

The URL should work as the one above does now: as a link on this forum, on Facebook or from a webpage. Desktop or mobile device.

GrowthSeeker wrote:
Fri Feb 07, 2020 12:51 am
Good question. I'm not a guru, but you could start by web scraping the first page to see how many posts there are. Then append "&start=N" where "N" is that number rounded down to the nearest multiple of 50. That gets you to the top of the last page.
I checked several pages, and the next step is to append "#pM" where M is a 7 digit number, but I can't quite figure that one out. Maybe easier to loop through tags that match the title of the page.
There seems to be a div tag and also an <a href="..." tag which each include that #pM code where M is a 7 digit number. If you could capture that and append it to the URL, you'd be in business.

But you probably already figured that much out. I don't know if there is a keyword, such as "#unread" which connotes the last post.
Yes, I’m thinking there must be a parameter (“lastpost” or “end”) that I can attach to the URL string.
Connect with Bogleheads in Northern California! Click the link under my user info/avatar.

User avatar
Topic Author
digarei
Posts: 888
Joined: Sat Jul 05, 2014 1:41 am
Location: Sacramento
Contact:

Re: How to create a URL for last post in topic?

Post by digarei » Fri Feb 07, 2020 10:54 am

sycamore wrote:
Fri Feb 07, 2020 7:14 am
It doesn't appear to be possible, at least based on this posting from 2016 from the phpBB forum (as you may know, bogleheads.org is powered by phpBB):

How to link to the last post of a topic (that still works after new posts are made)

That would be a nice feature, though.
Thanks, I read this phpBB support topic. Maddeningly, I don’t think the principal respondent completely understood what was being requested.

Although I see that “Last post” is a bit of a misnomer. What I wish to target is actually the “Latest post” in the thread.

phpBB is quite mature. I’m sure there’s a way to do this! :happy
Connect with Bogleheads in Northern California! Click the link under my user info/avatar.

User avatar
Peculiar_Investor
Posts: 1577
Joined: Thu Oct 20, 2011 12:23 am
Location: Staying home - Calgary, AB
Contact:

Re: How to create a URL for last post in topic?

Post by Peculiar_Investor » Fri Feb 07, 2020 11:01 am

Thanks for clarifying the use case. That helps.
digarei wrote:
Fri Feb 07, 2020 10:43 am
Other chapters advertise their upcoming meetings by creating a new post, which naturally falls to the bottom, chronologically. It’s the latest post that I wish to target, regardless of whether it has already been read by the user or others.
Not sure it exactly fulfills your needs, but if you click on the little icon before the "by <username>" on each post, that provides a link to the specific post.

For example, digarei's post above mine is viewtopic.php?p=5005467#p5005467. If I understand the use case above, that would be the link to provide.
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams

rkhusky
Posts: 9522
Joined: Thu Aug 18, 2011 8:09 pm

Re: How to create a URL for last post in topic?

Post by rkhusky » Fri Feb 07, 2020 11:06 am

This topic is numbered t=303073. This post of mine is numbered p=5005533. The numbering of topics and posts seems to be independent of each other. The trick is to figure out p=5005533, given t=303073 (or actually the last post number for a given topic number). You probably need a lookup table.

User avatar
Topic Author
digarei
Posts: 888
Joined: Sat Jul 05, 2014 1:41 am
Location: Sacramento
Contact:

Re: How to create a URL for last post in topic?

Post by digarei » Fri Feb 07, 2020 11:10 am

Peculiar_Investor wrote:
Fri Feb 07, 2020 11:01 am
Thanks for clarifying the use case. That helps.
digarei wrote:
Fri Feb 07, 2020 10:43 am
Other chapters advertise their upcoming meetings by creating a new post, which naturally falls to the bottom, chronologically. It’s the latest post that I wish to target, regardless of whether it has already been read by the user or others.
Not sure it exactly fulfills your needs, but if you click on the little icon before the "by <username>" on each post, that provides a link to the specific post.

For example, digarei's post above mine is viewtopic.php?p=5005467#p5005467. If I understand the use case above, that would be the link to provide.
Right. However, as soon as another post is made, that number changes. I’m looking for a static link that will work today and a year from now. One should be able to type it into a browser or post it on a web page and regardless of the number of posts made, clicking the link always goes to the latest post.
Connect with Bogleheads in Northern California! Click the link under my user info/avatar.

rkhusky
Posts: 9522
Joined: Thu Aug 18, 2011 8:09 pm

Re: How to create a URL for last post in topic?

Post by rkhusky » Fri Feb 07, 2020 11:14 am

prudent wrote:
Fri Feb 07, 2020 8:58 am
rkhusky wrote:
Fri Feb 07, 2020 8:28 am
The page at https://www.bogleheads.org has links to the last post in each thread.
It actually links to the first unread post, or if there are no unread posts it will go to the first post on the last page of the thread.
For me it almost always goes to the last post.

Is that posts unread by anyone or posts unread by me? If the latter, that info wouldn't be normally be available to bogleheads.org since I delete cookies whenever I close my browser.

User avatar
Peculiar_Investor
Posts: 1577
Joined: Thu Oct 20, 2011 12:23 am
Location: Staying home - Calgary, AB
Contact:

Re: How to create a URL for last post in topic?

Post by Peculiar_Investor » Fri Feb 07, 2020 11:22 am

rkhusky wrote:
Fri Feb 07, 2020 11:06 am
This topic is numbered t=303073. This post of mine is numbered p=5005533. The numbering of topics and posts seems to be independent of each other.
Yes they are independent.
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams

User avatar
Topic Author
digarei
Posts: 888
Joined: Sat Jul 05, 2014 1:41 am
Location: Sacramento
Contact:

Re: How to create URL for latest post in topic?

Post by digarei » Fri Feb 07, 2020 7:31 pm


Anyone else? I’m pretty sure that someone familiar with the phpBB code used with “Viewtopic” will have an answer. ~ Thanks!


Chapters advertise their upcoming meetings by creating a new post, which naturally falls to the bottom, chronologically. It’s the latest post that I wish to target, regardless of whether it has already been read.

I’m looking for a URL static link that will work today and a year from now. One should be able to type it into a browser or post it on a web page and regardless of the number of posts made, clicking the link always goes to the latest post.

The following URL sets the view to the top of page 3. I want to jump to the last page, bottom post when the list is sorted using default chronological ordering. Perhaps someone has a trick or workaround using the Hilite parameter?

Code: Select all

https://www.bogleheads.org/forum/viewtopic.php?f=9&t=161311&start=100
Connect with Bogleheads in Northern California! Click the link under my user info/avatar.

User avatar
Peculiar_Investor
Posts: 1577
Joined: Thu Oct 20, 2011 12:23 am
Location: Staying home - Calgary, AB
Contact:

Re: How to create URL for latest post in topic?

Post by Peculiar_Investor » Fri Feb 07, 2020 8:32 pm

Thinking outside the box a bit, would using the atom feed information (The Forum is now "Feed friendly") allow you to track/extract the last post URL?
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams

AlphaLess
Posts: 2627
Joined: Fri Sep 29, 2017 11:38 pm
Location: Kentucky

Re: How to create URL for latest post in topic?

Post by AlphaLess » Fri Feb 07, 2020 8:38 pm

You would think this would be an easy thing to implement on the server side, and then have something like

http://boglehead.org/url_to_topic?post=last
"A Republic, if you can keep it". Benjamin Franklin. 1787. | Party affiliation: Vanguard. Religion: low-cost investing.

User avatar
prudent
Moderator
Posts: 7507
Joined: Fri May 20, 2011 2:50 pm

Re: How to create URL for latest post in topic?

Post by prudent » Fri Feb 07, 2020 8:40 pm

If you change your User Control Panel -> Board Preferences -> Display Options -> Display Post Order Direction to Descending, will that solve the issue?

User avatar
Topic Author
digarei
Posts: 888
Joined: Sat Jul 05, 2014 1:41 am
Location: Sacramento
Contact:

Re: How to create URL for latest post in topic?

Post by digarei » Fri Feb 07, 2020 9:46 pm

prudent wrote:
Fri Feb 07, 2020 8:40 pm
If you change your User Control Panel -> Board Preferences -> Display Options -> Display Post Order Direction to Descending, will that solve the issue?
The solution would have to work for anyone who clicks the link, regardless of whether they are logged in to the forum. A standard URL that could direct users who aren’t necessarily Bogleheads.org members from another topic or separate web page. One can effect that currently with a URL that references the topic number by itself. When clicked it goes to the first post. I need one that goes to the latest post in the topic thread.
Connect with Bogleheads in Northern California! Click the link under my user info/avatar.

the way
Posts: 265
Joined: Sat Oct 26, 2019 6:00 pm

Re: How to create URL for latest post in topic?

Post by the way » Fri Feb 07, 2020 9:52 pm

This is the closest I could come up with, which is right after the last post on the last page

Code: Select all

https://www.bogleheads.org/forum/viewtopic.php?f=9&t=161311&start=999999#page-footer						
If you take off the # then you would go to the top of the last page.

User avatar
Topic Author
digarei
Posts: 888
Joined: Sat Jul 05, 2014 1:41 am
Location: Sacramento
Contact:

Re: How to create URL for latest post in topic?

Post by digarei » Fri Feb 07, 2020 10:10 pm

the way wrote:
Fri Feb 07, 2020 9:52 pm
This is the closest I could come up with, which is right after the last post on the last page

Code: Select all

https://www.bogleheads.org/forum/viewtopic.php?f=9&t=161311&start=999999#page-footer						
If you take off the # then you would go to the top of the last page.
This is a work-around yet it gets us 95% there. Thank you!

I think someone else mentioned using an HTML tag, above.

Until a cleaner way to display the latest post is revealed I will use this method.

Thanks again. :D
Connect with Bogleheads in Northern California! Click the link under my user info/avatar.

the way
Posts: 265
Joined: Sat Oct 26, 2019 6:00 pm

Re: How to create URL for latest post in topic?

Post by the way » Sat Feb 08, 2020 1:42 pm

You could also try using search since that allows you to specify ascending or descending. However, you'd need to guarantee that the keyword or author actually finds the post that you want. Also you have to click thru to actually post in the thread.

This will show the latest post first

Code: Select all

https://www.bogleheads.org/forum/search.php?keywords=&author=digarei&sd=d&t=161311#page-body
change to sd=a if you want to see the first post first.

the way
Posts: 265
Joined: Sat Oct 26, 2019 6:00 pm

Re: How to create URL for latest post in topic?

Post by the way » Sat Feb 08, 2020 4:24 pm

Hey, I just noticed at the bottom of each page there is a sort dropdown. Turns out sd=a and sd=d work by simply adding it to the very first URL you posted. This shows the last post first:

Code: Select all

https://www.bogleheads.org/forum/viewtopic.php?f=9&t=161311&st=0&sk=t&sd=d#page-body
change to sd=a if you want to see the first post first.

User avatar
Topic Author
digarei
Posts: 888
Joined: Sat Jul 05, 2014 1:41 am
Location: Sacramento
Contact:

Re: How to create URL for latest post in topic?

Post by digarei » Sun Feb 09, 2020 6:24 pm

. . .
the way wrote:
Sat Feb 08, 2020 4:24 pm
Hey, I just noticed at the bottom of each page there is a sort dropdown. Turns out sd=a and sd=d work by simply adding it to the very first URL you posted. This shows the last post first:

Code: Select all

https://www.bogleheads.org/forum/viewtopic.php?f=9&t=161311&st=0&sk=t&sd=d#page-body
change to sd=a if you want to see the first post first.

Great noticing…

Thank you!

Below syntax generalizes alternative ways to display the first or last post.


Display first post in a topic thread (default) [1st post on Top]

Code: Select all

 https://www.bogleheads.org/forum/viewtopic.php?f=FORUMNUMBER&t=TOPICNUMBER 

Display latest post in a topic thread [Last post on Bottom]

Code: Select all

 https://www.bogleheads.org/forum/viewtopic.php?f=FORUMNUMBER&t=TOPICNUMBER&start=999999#page-footer 

Create sorted list of posts for this topic, from latest to earliest post [Last post on Top]

Code: Select all

 https://www.bogleheads.org/forum/viewtopic.php?f=FORUMNUMBER&t=TOPICNUMBER&st=0&sk=t&sd=d#page-body 

Create a sorted list of posts for this topic from specified author, from latest to earliest post [Last post on Top]

Code: Select all

 https://www.bogleheads.org/forum/search.php?keywords=&author=AUTHORNAME&sd=d&t=TOPICNUMBER#page-body 

Create a sorted list of posts for this topic from specified author, from earliest to latest post [1st post on Top]

Code: Select all

 https://www.bogleheads.org/forum/search.php?keywords=&author=AUTHORNAME&sd=a&t=TOPICNUMBER#page-body 
. . .
Connect with Bogleheads in Northern California! Click the link under my user info/avatar.

Post Reply