We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Locked Topic
  • Pages:
  • 1
[ ! ] Autodirect to Last Post when Clicking Thread
Topic Started: Mar 8 2015, 12:05 PM (756 Views)
Kractero
Member Avatar
Member
[ * ]
Is there a way to only autodirect if you have not read the post? Automatically directing you to the last post is annoying.
Offline Profile Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
I put a code together to accomplish this effect, but it's not working properly and I cannot figure out why. It redirects to the first topic page no matter what the alt text of the topic marker is.
Code:
 
<script type="text/javascript">
$('td.c_last > a').click(function(e) {
e.preventDefault();
var topic = $(this).attr('href');

$.get(topic + '?force_ads', function(data) {
var forum = $('#nav a:last', data).attr('href');
$.get(forum + '?force_ads', function(nData) {
var alt = $('td.c_cat-title a[href="' + topic + '"]', nData).parents('tr[class*="row"]').find('td.c_cat-mark img').attr('alt');

if (alt.indexOf('(No new posts)') !== -1) {
window.location.href = topic + '1/';
} else {
window.location.href = topic;
}
});
});
});
</script>
I'll leave the code here for another coder to look at.
Offline Profile Goto Top
 
ItalicJupiter
Member
[ * ]
This code is not working. I tried it many times and its still not working. :zombie:
Offline Profile Goto Top
 
Moonface
Member Avatar


ItalicJupiter
Oct 1 2015, 01:21 AM
This code is not working. I tried it many times and its still not working. :zombie:
Cory stated the code does not work properly and that he hopes another coder can figure out why.
Offline Profile Goto Top
 
ItalicJupiter
Member
[ * ]
Its been 7 months. I'm not sure if Coder can figure it out. :/

Which one this code for...? JavaScript? Top of the Page? Or Above the Board..?
Edited by ItalicJupiter, Oct 1 2015, 03:12 PM.
Offline Profile Goto Top
 
DaPizzaMan
Member Avatar
#TeamSupport

@Cory: It's because you're actually loading the topic page when you use the GET request on the topic URL, which makes the topic icon always turn out to be the "No New" one.

For anyone who wants such a code, it wouldn't be realistic to achieve such a code.
Offline Profile Goto Top
 
Moonface
Member Avatar


ItalicJupiter
Oct 1 2015, 03:10 PM
Its been 7 months. I'm not sure if Coder can figure it out. :/

Which one this code for...? JavaScript? Top of the Page? Or Above the Board..?
The code simply does not work to send users to the last post in a thread automatically. Placing it anywhere on your board will be a waste. As DPM has pointed out, a code to achieve this isn't possible and therefore the code Cory supplied can not be fixed, and therefore is unusable to achieve an effect of sending users to the last post in a thread.
Offline Profile Goto Top
 
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
What should happen if they have read the post? Should it go to the first page?
Offline Profile Goto Top
 
DaPizzaMan
Member Avatar
#TeamSupport

Quozzo
Oct 1 2015, 04:11 PM
What should happen if they have read the post? Should it go to the first page?
Well, by default, if there is a new post (meaning the user has not read the topic), the user is sent to the new post. Any time after that, while there are no new posts, the user is sent to the top of the last page. So I assume when the user has read the new post, instead of going to the top of the last page, he/she should be sent to the first?

Technically the person who requested this didn't specify what he wants to do when the topic has been read.
Offline Profile Goto Top
 
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
DaPizzaMan
Oct 1 2015, 04:16 PM
Quozzo
Oct 1 2015, 04:11 PM
What should happen if they have read the post? Should it go to the first page?
Well, by default, if there is a new post (meaning the user has not read the topic), the user is sent to the new post. Any time after that, while there are no new posts, the user is sent to the top of the last page. So I assume when the user has read the new post, instead of going to the top of the last page, he/she should be sent to the first?

Technically the person who requested this didn't specify what he wants to do when the topic has been read.
It always goes to the last post in the last page when i've read all posts in a topic.

I know the OP didn't specify what should happen (hence the question ;) ) but I'm opening it up to the community to see if there is a consensus on the matter.
Offline Profile Goto Top
 
DaPizzaMan
Member Avatar
#TeamSupport

Quozzo
Oct 1 2015, 04:18 PM
DaPizzaMan
Oct 1 2015, 04:16 PM
Quozzo
Oct 1 2015, 04:11 PM
What should happen if they have read the post? Should it go to the first page?
Well, by default, if there is a new post (meaning the user has not read the topic), the user is sent to the new post. Any time after that, while there are no new posts, the user is sent to the top of the last page. So I assume when the user has read the new post, instead of going to the top of the last page, he/she should be sent to the first?

Technically the person who requested this didn't specify what he wants to do when the topic has been read.
It always goes to the last post in the last page when i've read all posts in a topic.

I know the OP didn't specify what should happen (hence the question ;) ) but I'm opening it up to the community to see if there is a consensus on the matter.
Yes, you're right. I was thinking about how that does not happen when #new is removed from the URL. Which doesn't happen when clicking on a topic URL from anywhere unless specifying a page number.

If I may ask, what would you plan to do based on the answer to your question?
Offline Profile Goto Top
 
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
DaPizzaMan
Oct 1 2015, 04:31 PM
Quozzo
Oct 1 2015, 04:18 PM
DaPizzaMan
Oct 1 2015, 04:16 PM
Quozzo
Oct 1 2015, 04:11 PM
What should happen if they have read the post? Should it go to the first page?
Well, by default, if there is a new post (meaning the user has not read the topic), the user is sent to the new post. Any time after that, while there are no new posts, the user is sent to the top of the last page. So I assume when the user has read the new post, instead of going to the top of the last page, he/she should be sent to the first?

Technically the person who requested this didn't specify what he wants to do when the topic has been read.
It always goes to the last post in the last page when i've read all posts in a topic.

I know the OP didn't specify what should happen (hence the question ;) ) but I'm opening it up to the community to see if there is a consensus on the matter.
Yes, you're right. I was thinking about how that does not happen when #new is removed from the URL. Which doesn't happen when clicking on a topic URL from anywhere unless specifying a page number.

If I may ask, what would you plan to do based on the answer to your question?
...this...

Code:
 
$('.c_cat-title').find('a:last').click(function(e){
var $this = $(this), noNew = $this.closest('tr').find('.c_cat-mark img[alt~="new"]').length;
if(noNew){
e.preventDefault();
location.href=$this.attr('href')+"1/";
}
});


it just opens the first page. Edit the value for `location.href` as you see fit :P

Oops. made a booboo
Edited by Quozzo, Oct 1 2015, 04:44 PM.
Offline Profile Goto Top
 
DaPizzaMan
Member Avatar
#TeamSupport

And what about clicking a topic link from the index?
Offline Profile Goto Top
 
Quozzo
Member Avatar
By the blood of Sanguinius!
[ *  *  *  *  * ]
DaPizzaMan
Oct 1 2015, 04:48 PM
And what about clicking a topic link from the index?
Oh right, yeah. I never do that. That would require AJAX (as Cory did). If the board orders the topics by last post then entering the forum and using my code above would suffice (as it would be the top topic (unless there has been another post in the space of the page loading and the user clicking the link)). But if it's ordered by OP like the request forum then it wont work.

I thought specifying a user (like this) might have worked, but alas, ZB is being ZB!
Offline Profile Goto Top
 
DaPizzaMan
Member Avatar
#TeamSupport

Quozzo
Oct 1 2015, 05:04 PM
DaPizzaMan
Oct 1 2015, 04:48 PM
And what about clicking a topic link from the index?
Oh right, yeah. I never do that. That would require AJAX (as Cory did). If the board orders the topics by last post then entering the forum and using my code above would suffice (as it would be the top topic (unless there has been another post in the space of the page loading and the user clicking the link)). But if it's ordered by OP like the request forum then it wont work.

I thought specifying a user (like this) might have worked, but alas, ZB is being ZB!
Even then, what if the topic is in a subforum? Then you'll have to look through the forum and each of its subforums until you find the topic.
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Closed Requests · Next Topic »
Locked Topic
  • Pages:
  • 1