Welcome Guest [Log In] [Register]
Support Staff Recommendation
All communities remaining on zIFBoards/InvisionFree should check their conversion opt-in selection in their Admin CP (menu item Tapatalk Conversion)
(Read More)
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:
Multiquote (on) Multiquote (off)
Add Reply
Active Topics in Sidebar
Topic Started: Mar 29 2012, 10:14 AM (20,039 Views)
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Code Name: Active Topics in Sidebar

What the code does: Preview

How to use the code: Install as instructed. The only thing you need to edit is the amount variable, which can be a range from 1 to 20, 1 being one latest post will display, 20 being twenty latest posts will display.

How to install the code:

Admin CP Posted Image Themes Posted Image Board Template Posted Image Javascripts
Code:
 
<style type="text/css">
div.margin {
margin-left: 220px !important;
}
</style>
Admin CP Posted Image Themes Posted Image Board Template Posted Image Below the Board
Code:
 
<script type="text/javascript">
//<![CDATA[
(function($) {
var amount = '5';
if (location.href.indexOf('/site') === -1 && location.href.indexOf('/search/?c=5') === -1) {
$('#main').before('<div id="sidebar" style="padding: 10px; width: 200px; position: absolute"><div id="portal"><div id="latest" class="portal_box"><h2>Latest Posts</h2></div><div></div>');
$('#main').addClass('margin');

$.get(main_url + 'search/?c=5&force_ads', function(data) {
$('tr[class*="row"]:lt(' + amount + ')', data).each(function() {
var replies = $(this).find('td.c_cat-replies a').text();
var repliesLink = $(this).find('td.c_cat-replies a').attr('href');
var tTitle = $(this).find('td.c_cat-title:eq(0) > a').text();
var tTitleLink = $(this).find('td.c_cat-title:eq(0) > a').attr('href');
var lPoster = $(this).find('td.c_cat-lastpost a').text();
var lPosterLink = $(this).find('td.c_cat-lastpost a').attr('href');
$('#latest').append('<h4><a href="' + tTitleLink + '">' + tTitle + '</a></h4><div class="portal_content"><a href="' + lPosterLink + '">' + lPoster + '</a><br />Replies: <a href="' + repliesLink + '" rel="nofollow">' + replies + '</a></div>');
});
var sidebarHeight = $('#sidebar').height();
$('#main').css('min-height', sidebarHeight + 'px');
$.get(location.href);
});
}
})(jQuery);
//]]>
</script>
Edited by Cory, Dec 1 2016, 12:56 PM.
Offline Profile Quote Post Goto Top
 
Replies:
Q_Q
Member
[ * ]
I've tried it unsuccessfully by adding the code to the theme layout (above the header), and also in the board template (below the board). Where should I add it instead?
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
You have the JavaScript code added twice. Add the HTML so I can see what you're doing wrong.
Offline Profile Quote Post Goto Top
 
Q_Q
Member
[ * ]
Cory
Nov 9 2017, 08:14 PM
Install my sidebar code then use this code instead of the one in the OP:
Code:
 
<script type="text/javascript">
//<![CDATA[
(function($) {
var amount = '5';
if (location.href.indexOf('/site') === -1 && location.href.indexOf('/search/?c=5') === -1) {
$('#sidebar').append('<div id="latest" class="portal_box"><h2>Latest Posts</h2></div>');

$.get(main_url + 'search/?c=5&force_ads', function(data) {
$('tr[class*="row"]:lt(' + amount + ')', data).each(function() {
var replies = $(this).find('td.c_cat-replies a').text();
var repliesLink = $(this).find('td.c_cat-replies a').attr('href');
var tTitle = $(this).find('td.c_cat-title:eq(0) > a').text();
var tTitleLink = $(this).find('td.c_cat-title:eq(0) > a').attr('href');
var lPoster = $(this).find('td.c_cat-lastpost a').text();
var lPosterLink = $(this).find('td.c_cat-lastpost a').attr('href');
$('#latest').append('<h4><a href="' + tTitleLink + '">' + tTitle + '</a></h4><div class="portal_content"><a href="' + lPosterLink + '">' + lPoster + '</a><br />Replies: <a href="' + repliesLink + '" rel="nofollow">' + replies + '</a></div>');
});
var sidebarHeight = $('#sidebar').height();
$('#main').css('min-height', sidebarHeight + 'px');
$.get(location.href);
});
}
})(jQuery);
//]]>
</script>

Alright! I got it working. I wasn't clear before what you meant by using this code instead of the one in the OP since we're on two threads!
So the correct method to combine this activity + editable HTML sidebar boxes was installing the sidebar code as is, and then adding your new code below the board!

Thank you very much!
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Glad you got it to work!

I made one tiny mistake that will make the box lack style.
Code:
 
$('#sidebar').append
Change that to this:
Code:
 
$('#sidebar #portal').append
Offline Profile Quote Post Goto Top
 
Q_Q
Member
[ * ]
Thank you! That's much easier than changing the css manually!

I have one (hopefully last) question?
I want this code to only show up on my index, but while adding 'if (location.href.indexOf('/index') !== -1) ' works for the active topics, the sidebar code still shows up on every page. Is it possible to make both only appear on the index?
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Remove this from the CSS:
Code:
 
#main {
margin-left: 170px !important;
}
Add this to the bottom of the Theme Layout:
Code:
 
<script type="text/javascript">
if (location.href.indexOf('/index/') === -1) {
$('#sidebar').hide();
} else {
$('#main').css('margin-left', '170px');
}
</script>
Offline Profile Quote Post Goto Top
 
Q_Q
Member
[ * ]
Thank you! It's working perfectly now!
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