A button to show only the topic starter's posts
3 posters
Page 1 of 1
A button to show only the topic starter's posts
Hello. This is my forum: click it
I need a button in a topic to click to show only the topic starter's posts.
And this is the explanatory diagram by @Winging.
So I have tried like this:
But this code can be worked only in the first page.
I can not find the code which can catch the topic starter. And that is the key to create it.
I hope to get your help here.
Thank you for reading!
I need a button in a topic to click to show only the topic starter's posts.
And this is the explanatory diagram by @Winging.
So I have tried like this:
- Code:
$(function(){
$("#author_only").click(function(e){
e.preventDefault();
var id=$(".postrow").first().find(".poster_name").find("a").text();
id='{TOPIC_POSTER}';
if($(this).hasClass("only")){
$(this).removeClass("only").text("只看作者(It means only see the topic starter's posts)");
$(".postrow").show();
}
else{
$(this).addClass("only").text("顯示其他評論(It means see all posts)");
$(".postrow").map(function(){
if($(this).find(".poster_name").find("a").text()!=id){
$(this).hide();
}
});
}
But this code can be worked only in the first page.
I can not find the code which can catch the topic starter. And that is the key to create it.
I hope to get your help here.
Thank you for reading!
Re: A button to show only the topic starter's posts
Hello @nina81331,
Welcome to Forumotion Support Forum! But your code is working? Because i see a lot of errors
Welcome to Forumotion Support Forum! But your code is working? Because i see a lot of errors
Go to Adminstration Panel > General > Messages and emails > Configuration in the option "Always show the first post in the topics" mark as "Yes"!But this code can be worked only in the first page.
I can not find the code which can catch the topic starter. And that is the key to create it.
Re: A button to show only the topic starter's posts
Hi. You can get the topic starter using jQuery to get the first page and read the posts from there.
But I wouldn't do it like that, because even with that you are only filtering the posts on the current page. In some cases there could be no posts by the topic starter on that page so the result would be empty, which is a bit weird.
What I would do is get the posts of all the pages of the topic, so when you are "filtering" you are not restrained on topic pages at all. With that you can also easily make a filter by another of the active users on that topic.
The second widget on this topic could help you a bit with that: Widgets for categories and posts
Hope it helps.
- Code:
function current_topic(){
return window.location.href.replace(/\/t(\d*)p(\d*)-/, "/t$1-").replace(/\#(\d*)$/, "");
}
$.get(current_topic(), function(d){
var post = $(".post", d)[0];
console.log(post); // First post
});
But I wouldn't do it like that, because even with that you are only filtering the posts on the current page. In some cases there could be no posts by the topic starter on that page so the result would be empty, which is a bit weird.
What I would do is get the posts of all the pages of the topic, so when you are "filtering" you are not restrained on topic pages at all. With that you can also easily make a filter by another of the active users on that topic.
The second widget on this topic could help you a bit with that: Widgets for categories and posts
Hope it helps.
Wecoc- Forumember
- Posts : 144
Reputation : 111
Language : Catalan, Spanish, English
TonnyKamper likes this post
Similar topics
» I would like to have a widget for TOP TOPIC STARTERS
» Widget for Most Active Topic Starters
» Guests cannot view quote button or reply to posts in a topic
» Avatar in: Top posters, all Top posting and Most active topic starters Widget
» How to show posts?
» Widget for Most Active Topic Starters
» Guests cannot view quote button or reply to posts in a topic
» Avatar in: Top posters, all Top posting and Most active topic starters Widget
» How to show posts?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum