Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Support
  • Code University
  • [IF] Is there a way to detect if topic is pinned in topic view?
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
[IF] Is there a way to detect if topic is pinned in topic view?
Tweet Topic Started: Jun 28 2009, 07:00 PM (204 Views)
Gorgor Jun 28 2009, 07:00 PM Post #1
Hello

Posts:
1,187
Group:
Former Staff
Member
#2,728
Joined:
Apr 2, 2009
Coding language
PHP
Hi, I was wondering if in Invisionfree it's possible to detect if a topic is pinned when you're viewing the topic? The only thing that I could think of is if you locate the moderator option for unpin or pin, but regular users can't find that. I'm trying to code something like my locked image/text code, but I just need this little piece.

Thanks :)
Offline Profile Goto Top
 
Reid Jun 28 2009, 07:06 PM Post #2
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
I don't think so. I don't see one, anyways. :P
The Resource Board
Offline Profile Goto Top
 
Gorgor Jun 28 2009, 07:39 PM Post #3
Hello

Posts:
1,187
Group:
Former Staff
Member
#2,728
Joined:
Apr 2, 2009
Coding language
PHP
Hmm... I was thinking that there might not be a way. I could still do it manually by using the location.href.match code and filling in each topic number, but that would take a while.

Are you positive that there's no way?
Offline Profile Goto Top
 
Reid Jun 28 2009, 08:15 PM Post #4
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
There is always AJAX..
Code:
 
var c = document.getElementById('navstrip').getElementsByTagName('a'), xhr = XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"), topic_name = null;
c = c[c.length-1].href;
xhr.open("GET",c,true);
xhr.onreadystatechange = function(){
if ((xhr.readyState == 4 || xhr.readyState == 'complete') && xhr.status == 200) {
var b = document.getElementsByTagName('b'), l = b.length;
while (l--) {
if (b[l].parentNode.className.indexOf("maintitle")!=-1) {
topic_name = b[l].innerHTML;
}
}
var temp_ele = document.createElement('div');
temp_ele.innerHTML = xhr.responseText;
b = temp_ele.getElementsByTagName('b'), l = b.length;
while (l--) {
if (b[l].innerHTML.indexOf("Pinned:")!=-1 && b[l].getElementsByTagName('a')[0].innerHTML.indexOf(topic_name)!=-1) {
document.getElementById('navstrip').innerHTML += "<div align='center'>This is a pinned topic.</div>";
}
}
}
}
xhr.send(null);
The Resource Board
Offline Profile Goto Top
 
Gorgor Jun 28 2009, 08:27 PM Post #5
Hello

Posts:
1,187
Group:
Former Staff
Member
#2,728
Joined:
Apr 2, 2009
Coding language
PHP
Hmm... I don't know a thing about AJAX :P So would that go in footers like usual surrounded by the <script> tag?
Offline Profile Goto Top
 
Reid Jun 28 2009, 08:32 PM Post #6
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
Yeah. AJAX is pretty advanced. I wouldn't try dealing too much with it when you're first doing JS. :P
The Resource Board
Offline Profile Goto Top
 
Gorgor Jun 28 2009, 08:47 PM Post #7
Hello

Posts:
1,187
Group:
Former Staff
Member
#2,728
Joined:
Apr 2, 2009
Coding language
PHP
It's a great code, but I edited this so it would go on the same line as where I put my locked topic text/image code. I put this code you made before it, but the locked image will come before it and I want the pinned one to come before the locked one. Do you know any way to make it like that?

Here's a link to a locked and pinned topic on my forums (not sure if you need this or not): http://z8.invisionfree.com/Living_Light_Empire/index.php?showtopic=350

Thank you.
Offline Profile Goto Top
 
Reid Jun 28 2009, 08:52 PM Post #8
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
You can stick the locked topic code after the last while loop in the code above and it will do it.
The Resource Board
Offline Profile Goto Top
 
Gorgor Jun 28 2009, 08:55 PM Post #9
Hello

Posts:
1,187
Group:
Former Staff
Member
#2,728
Joined:
Apr 2, 2009
Coding language
PHP
Wonderful. Thank you SO much! :D
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Code University · Next Topic »
Locked Topic

Track Topic · E-mail Topic Time: 7:46 PM Jul 10
Hosted for free by ZetaBoards · Privacy Policy