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:
Add Reply
  • Pages:
  • 1
  • 2
News Box
Topic Started: Jul 24 2010, 08:03 PM (5,346 Views)
ProAyanami
Member Avatar
The Coder
[ *  * ]
News Box
Description: Gets the first post from a topic and displays it as news.

Preview: http://s1.zetaboards.com/ProTestBoard/index/



The Code:
Code:
 
<script type="text/javascript">
var news_title = "News"
if(window.location==main_url + "index/"){
document.write('<style>.editby{display:none;}</style>')
var topic_id = "3619195"
$.get(main_url + "topic/" + topic_id + "/1/",function(Q){
$("div.category:first").prepend('<div id="News" style="margin-bottom:15px;"><div class="category"><table class="cat_head"><tbody><tr><td><h2>' + news_title + '</h2></td></tr></tbody></table><table cellpadding="0" cellspacing="0"><tbody><tr><td style="width: 75%;" valign="center">' + $(".c_post:first",Q).html() + '</td></tr></tbody></table></div></div>');
});
}
</script>


Extra Notes:
Change news_title to the news box title you want. Change topic_id to the topic id that you want used. To update news box, just edit your first post there. It's that easy to use.

Goes below the board.
Edited by ProAyanami, Jul 25 2010, 05:40 PM.
Offline Profile Quote Post Goto Top
 
Replies:
.awd (R)
Member Avatar
Member
[ *  *  * ]
Thank you for this. Also thanks for the "null" feature to guests
Offline Profile Quote Post Goto Top
 
Ferby
Member Avatar
Developer
[ *  *  *  *  * ]
Two questions

1. Would I be allowed to edit it?
2. Is there a way I could add this so it only applies for a certain forum instead of the whole site?
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Change 'index/' to 'forum/FORUM_ID/' to make it display on an individual forum instead of the index, change FORUM_ID as necessary.

I'm not sure what you mean by edit it, edit what exactly?
Online Profile Quote Post Goto Top
 
DarkGizmo-ZNR
Member Avatar
Who ate all the pecan sandies?
[ * ]
Great code! It'd be great if it can be dismissible though. Is that possible to add?
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Code:
 
<script type='text/javascript' src='http://z3.ifrm.com/313/104/0/p312803/zeta_cookie.js'></script>
Add that to the Javascripts wrapper of your Board Template if it's not already there.
Code:
 
<script type="text/javascript">
$(window).load(function () {
$('#News h2').append('<span style="float: right; font-style: italic; cursor: pointer" id="dismiss">Dismiss</span>');

var dismiss = zeta_cookie.get('dismiss');
if (dismiss) $('#News').remove();

$('#dismiss').click(function () {
$(this).parents('#News').remove();
zeta_cookie.set('dismiss', 'dismiss', 365);
});
});
</script>
Place that below this code (the code in the first post of this topic).
Online Profile Quote Post Goto Top
 
DarkGizmo-ZNR
Member Avatar
Who ate all the pecan sandies?
[ * ]
Cory, I added the codes you posted and still don't see the "Dismiss" button. See here.
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
I don't see either code on your forum.
Online Profile Quote Post Goto Top
 
DarkGizmo-ZNR
Member Avatar
Who ate all the pecan sandies?
[ * ]
Sorry. I removed it. The dismiss button wasn't appearing and the code itself suddenly stopped working/displaying so I just removed it from my wrappers.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · ZetaBoards Codes & Modifications · Next Topic »
Add Reply
  • Pages:
  • 1
  • 2