Hello,
in received email it is following link, which points to the last unread post: /Forum/viewtopic.php?f=5&t=1&e=1&view=unread#unread
It is possible to jump to the anchor #unread, after page with this link is loaded?
Thank you.
how to jump to #unread anchor
- axew3
- w3all User
- Posts: 2883
- Joined: Fri Jan 22, 2016 5:15 pm
- Location: Italy
- Contact:
Re: how to jump to #unread anchor
yes, you read on my mind thank you for report, known problem.
FIXEDV6 will fix this, and any redirected link like these (as well any other):
added on queue into this thread
https://www.axew3.com/w3/forums/viewtop ... f=2&t=1585
where V5 code has been also reported to be patched to fix something else in the while.
I will check to fix on fly if i can find out a moment, even before V6
FIXED
Code: Select all
https://www.phpbb.com/community/viewtopic.php?f=496&t=2554596&e=1&view=unread#unread
https://www.axew3.com/w3/forums/viewtop ... f=2&t=1585
where V5 code has been also reported to be patched to fix something else in the while.
I will check to fix on fly if i can find out a moment, even before V6
- axew3
- w3all User
- Posts: 2883
- Joined: Fri Jan 22, 2016 5:15 pm
- Location: Italy
- Contact:
Re: how to jump to #unread anchor
The V5 overall_footer.html code has been updated to resolve this issue:
https://www.axew3.com/w3/2020/01/phpbb- ... iframe-v5/
To fix:
on added overall_footer.html js code, find this line:
immediately after, add this:
remember to recompile phpBB template.
Note that the code search for h3 elements, containing a elements, than containing strings like this viewtopic.php?p=
so on theme DOM, the posts titles links, needs to exists wrapped like they are into default subsilver, or this line:
$( "h3 > a" ).each(function (e) {
need to change selectors to match on DOM correct post's a links.
Work fine into all themes where post's links a elements are inside an h3 element, like it is on prosilver, but into all themes?
In case as said, the line of code that search for elements on DOM need to be changed to match.
Do not know if there is another way than this to achieve and resolve. I do not think that there is, at moment.
https://www.axew3.com/w3/2020/01/phpbb- ... iframe-v5/
To fix:
on added overall_footer.html js code, find this line:
Code: Select all
var hash = window.location.hash.substr(1);
Code: Select all
if( hash == 'unread' ){
var postN = 1;
$( "h3 > a" ).each(function (e) { // need to match on DOM
ns = this.href.split('#p');
if( typeof ns != 'undefined' && /viewtopic.php\?p=/ig.exec(this.href) != null ){
if(ns[1] > postN){
w3lh = ns[1];
}
}
})
if( typeof w3lh != 'undefined' ){
hash = "p" + w3lh;
}
}
Note that the code search for h3 elements, containing a elements, than containing strings like this viewtopic.php?p=
so on theme DOM, the posts titles links, needs to exists wrapped like they are into default subsilver, or this line:
$( "h3 > a" ).each(function (e) {
need to change selectors to match on DOM correct post's a links.
Work fine into all themes where post's links a elements are inside an h3 element, like it is on prosilver, but into all themes?
In case as said, the line of code that search for elements on DOM need to be changed to match.
Do not know if there is another way than this to achieve and resolve. I do not think that there is, at moment.
Re: how to jump to #unread anchor
Hello,
I can confirm that code works. I changed selector based on my page structure. Thank you
I can confirm that code works. I changed selector based on my page structure. Thank you
Re: how to jump to #unread anchor
Hello,
I found problem with this code - If I click to URL with #unread anchor, then page jumps to the latest post instead of the latest unread post.
I found problem with this code - If I click to URL with #unread anchor, then page jumps to the latest post instead of the latest unread post.
- axew3
- w3all User
- Posts: 2883
- Joined: Fri Jan 22, 2016 5:15 pm
- Location: Italy
- Contact:
Re: how to jump to #unread anchor
It scroll to last post, but should instead scroll to, the last unread post, which could be not the last one inserted on thread, when there are more new replies? Do not know how it work, not checked deeply in true, so i will check asap how phpBB execute this task, and how to mimic it.
P.s i see it exist a template S_LOAD_UNREADS var which
so i assume it is the easy and correct way to accomplish with this
mh... just checked, no it is not the way ... let see asap more deeply
p.s
and on fly, i see that could be possible checking for class unreadpost, so the above code need to be little changed to achieve correctly the result
so i assume it is the easy and correct way to accomplish with this
mh... just checked, no it is not the way ... let see asap more deeply
p.s
and on fly, i see that could be possible checking for class unreadpost, so the above code need to be little changed to achieve correctly the result