Like SystemiConnectFri 15 Oct 2021, 04:50
Auto Save MessagesLGforumFri 26 Feb 2021, 13:31
New tutorial questionTheCrowMon 15 Feb 2021, 08:12
Support iOS Emojis (and other platforms)LGforumSun 14 Feb 2021, 01:25
LGforum (2806)
New latest topics box Vote_lcapNew latest topics box Voting_barNew latest topics box Vote_rcap 
Mr.Easybb (1587)
New latest topics box Vote_lcapNew latest topics box Voting_barNew latest topics box Vote_rcap 
Bloodbath (745)
New latest topics box Vote_lcapNew latest topics box Voting_barNew latest topics box Vote_rcap 
Rukiafan (533)
New latest topics box Vote_lcapNew latest topics box Voting_barNew latest topics box Vote_rcap 
Dom (513)
New latest topics box Vote_lcapNew latest topics box Voting_barNew latest topics box Vote_rcap 
puppycheese (446)
New latest topics box Vote_lcapNew latest topics box Voting_barNew latest topics box Vote_rcap 
pedro (330)
New latest topics box Vote_lcapNew latest topics box Voting_barNew latest topics box Vote_rcap 
Neymar (301)
New latest topics box Vote_lcapNew latest topics box Voting_barNew latest topics box Vote_rcap 
Hitsu (281)
New latest topics box Vote_lcapNew latest topics box Voting_barNew latest topics box Vote_rcap 
Flora (275)
New latest topics box Vote_lcapNew latest topics box Voting_barNew latest topics box Vote_rcap 


New latest topics box

avatarSchiggysboard
Status : No status yet...

Posts : 145
Join date : 2012-01-08
Sat 17 Jan 2015, 20:42
Hi guys,
in my forum we have the box "Latest Topics". But now I would like to have a new box like this but only for a selected Forum. (for instance only a box for the moderation team with the newest topics from the moderation forum)

Is this possible? This is the forum I mean. Is this possible with rss? With the newest 10 Topics?

Greetings.
avatarGuest
Sat 17 Jan 2015, 23:12
do you want this in a widget or you want to attach it somewhere else .. also whats your forum version
Ange TuteurAnge Tuteur
Status : No status yet...

Posts : 109
Join date : 2014-02-18
Age : 28
Location : North America
Sun 18 Jan 2015, 07:03
I have a widget that I usually use to load topics from specific forums. I just rewrote it a little bit from the original purpose of what I used it for. I use a bit of AJAX and some localStorage, so I don't constantly send a request on page change.

Add this to a widget :
Code:
[panda=html]<div id="loadedTopics-a" class="topicBox">
  <noscript>Unable to get topics, please enabled JavaScript to use this widget.</noscript> 
</div><a href="#" class="refresh">Refresh</a>
<script type="text/javascript">//<![CDATA[
(function() {
  var forum_id = 101,
      recent_count = 6,
      title_length = 30,
      cache_time = 29*60*1000,
      storage = window.localStorage,
      block = document.getElementById('loadedTopics-a');
 
  if (storage['topics'+forum_id] && storage['topicsExp'+forum_id] > +new Date - cache_time) block.innerHTML = storage['topics'+forum_id];
  else loadTopics();
  block.nextSibling.onclick = function() {
    for (var i=0,a=block.childNodes; i<a.length; i++) a[i].innerHTML = 'loading...';
    loadTopics();
    return false;
  };
  function loadTopics() {
    jQuery(block).load('/f'+forum_id+'- .forumbg:not(.forumbg.announcement) a.topictitle:lt('+recent_count+')',function() {
      for (var i=0,a=block.childNodes; i<a.length; i++) if (a[i].innerHTML.length > title_length) a[i].innerHTML = a[i].innerHTML.slice(0,title_length).trim() + '...';
      if (storage) storage['topics'+forum_id] = block.innerHTML, storage['topicsExp'+forum_id] = +new Date;
    });
  };
})();
//]]></script>

There's a few things you can use to customize the results of the widget.

forum_id : the id of the forum you want to load
recent_count : the amount of topics you want to display
title_length : the max amount of characters you want in the topic title
cache_time : the amount of time the topics are cached. mm*ss*ms

You can use the refresh button to forcefully refresh the widget, basically update the localStorage for the widget. If you make any changes, just click refresh so they take effect on your end.

Then add some CSS for the topic title style :
Code:
[panda=css].topicBox a.topictitle {
  color:#666;
  background:#EEE;
  border:1px solid #CCC;
  border-radius:3px;
  display:block;
  margin:2px 0;
  padding:3px;
}

That's mostly the method I use, but if there's better way, feel free. I'm not the best lol!


Ohh if you want to change who sees it, just edit the widget permissions by clicking the following bouton. New latest topics box Perms10
Dark-AvengerDark-Avenger
Status : Hello

Posts : 166
Join date : 2013-10-27
Age : 49
Sun 18 Jan 2015, 11:04
Hello,
Is it available for punbb too?
Ange TuteurAnge Tuteur
Status : No status yet...

Posts : 109
Join date : 2014-02-18
Age : 28
Location : North America
Sun 18 Jan 2015, 11:47
Dark-Avenger wrote:[quotelink="http://www.avacweb.com/t2299-new-latests-topics-box#21826"]Hello,
Is it available for punbb too?

Just remove .forumbg:not(.forumbg.announcement) from the selection in the load() method.
Dark-AvengerDark-Avenger
Status : Hello

Posts : 166
Join date : 2013-10-27
Age : 49
Sun 18 Jan 2015, 11:51
Thank you very much Ange its working but it displays the global announcements. Is there a way to bypass them?
avatarSchiggysboard
Status : No status yet...

Posts : 145
Join date : 2012-01-08
Wed 21 Jan 2015, 21:07
Hi, thank you very much Smile

It is possible to write the authors of the topics under the links like in the classic module? And it is possible to show two or more forums in this module? Like Forum number 101 and 27?
Ange TuteurAnge Tuteur
Status : No status yet...

Posts : 109
Join date : 2014-02-18
Age : 28
Location : North America
Thu 22 Jan 2015, 13:46
Schiggysboard wrote:[quotelink="http://www.avacweb.com/t2299-new-latests-topics-box#21877"]Hi, thank you very much Smile

It is possible to write the authors of the topics under the links like in the classic module? And it is possible to show two or more forums in this module? Like Forum number 101 and 27?
Just repaste the code into another widget, but make sure to change loadedTopics-a to something different like loadedTopics-b. Then all you need to do is change the settings. It can be done, but it would be a bit request heavy seeing as you'll have to get the first page of each topic in the list to find the author.
avatarSchiggysboard
Status : No status yet...

Posts : 145
Join date : 2012-01-08
Thu 22 Jan 2015, 15:41
Ange Tuteur wrote:[quotelink="http://www.avacweb.com/t2299-new-latests-topics-box#21886"]
Schiggysboard wrote:[quotelink="http://www.avacweb.com/t2299-new-latests-topics-box#21877"]Hi, thank you very much Smile

It is possible to write the authors of the topics under the links like in the classic module? And it is possible to show two or more forums in this module? Like Forum number 101 and 27?
Just repaste the code into another widget, but make sure to change loadedTopics-a to something different like loadedTopics-b. Then all you need to do is change the settings. It can be done, but it would be a bit request heavy seeing as you'll have to get the first page of each topic in the list to find the author.
This is not my point. I would like to have it in one widget.
And what do mean about the authors?
Ange TuteurAnge Tuteur
Status : No status yet...

Posts : 109
Join date : 2014-02-18
Age : 28
Location : North America
Fri 23 Jan 2015, 20:27
Okay, then you can paste it below the code in your current widget. It can be in the same widget or another, anywhere HTML formats.
avatarSchiggysboard
Status : No status yet...

Posts : 145
Join date : 2012-01-08
Sat 24 Jan 2015, 16:40
yeah, but is it possible in one list? So I have one Widget and one list (with 10 Threads) but the threads are out of two forums? So I get in my (one) list alle the newest topics from two forums?
avatarSchiggysboard
Status : No status yet...

Posts : 145
Join date : 2012-01-08
Fri 17 Apr 2015, 20:51
push/bump: Is it not possible that we have the same result but with the topics of two forums? Or a category? Its like that: I have the graphic forums which is subdivided into two subforums ("GFX Forum" and "Sprite-Forum" for instance). Is it possible to have in the box both? The newest topics from the "GFX Forum" and "Sprite-Forum"?
Ange TuteurAnge Tuteur
Status : No status yet...

Posts : 109
Join date : 2014-02-18
Age : 28
Location : North America
Sun 19 Apr 2015, 20:47
Give this a try :
Code:
[panda=js]<div id="loadedTopics" class="topicBox">
  <noscript>Unable to get topics, please enabled JavaScript to use this widget.</noscript> 
</div><a href="#" class="refresh">Refresh</a>
<script type="text/javascript">//<![CDATA[
(function() {
  var forum_id = [101, 102],
      recent_count = 6,
      title_length = 30,
      cache_time = 29*60*1000,
      storage = window.localStorage,
      block = document.getElementById('loadedTopics'),
      a = 0, b = forum_id.length;
 
  if (storage.faTopics && storage.faTopicsExp > +new Date - cache_time) block.innerHTML = storage.faTopics;
  else getTopics();
  block.nextSibling.onclick = function() {
    getTopics();
    return false;
  };
 
  function getTopics() {
    jQuery.get('/f' + forum_id[a], function(d) {
      for (var n = $('.forumbg:not(.forumbg.announcement) a.topictitle', d), i = 0; i<recent_count; i++) block.appendChild(n[i]);
     
      if (a < b) {
        a++;
        getTopics();
      } else if (storage) {
        storage.faTopics = block.innerHTML;
        storage.faTopicsExp = +new Date;
      }
    });
  };
})();
//]]></script>

The forum_id is an array, so you can place multiple IDs separated by a comma.
avatarSchiggysboard
Status : No status yet...

Posts : 145
Join date : 2012-01-08
Sat 25 Apr 2015, 19:46
Ange Tuteur wrote:[quotelink="http://www.avacweb.com/t2299-new-latests-topics-box#23020"]Give this a try :
Code:
[panda=js]<div id="loadedTopics" class="topicBox">
  <noscript>Unable to get topics, please enabled JavaScript to use this widget.</noscript> 
</div><a href="#" class="refresh">Refresh</a>
<script type="text/javascript">//<![CDATA[
(function() {
  var forum_id = [101, 102],
      recent_count = 6,
      title_length = 30,
      cache_time = 29*60*1000,
      storage = window.localStorage,
      block = document.getElementById('loadedTopics'),
      a = 0, b = forum_id.length;
 
  if (storage.faTopics && storage.faTopicsExp > +new Date - cache_time) block.innerHTML = storage.faTopics;
  else getTopics();
  block.nextSibling.onclick = function() {
    getTopics();
    return false;
  };
 
  function getTopics() {
    jQuery.get('/f' + forum_id[a], function(d) {
      for (var n = $('.forumbg:not(.forumbg.announcement) a.topictitle', d), i = 0; i<recent_count; i++) block.appendChild(n[i]);
     
      if (a < b) {
        a++;
        getTopics();
      } else if (storage) {
        storage.faTopics = block.innerHTML;
        storage.faTopicsExp = +new Date;
      }
    });
  };
})();
//]]></script>

The forum_id is an array, so you can place multiple IDs separated by a comma.
no this does not work :/
avatarSchiggysboard
Status : No status yet...

Posts : 145
Join date : 2012-01-08
Sun 26 Apr 2015, 14:46
Now it's working, adding ";" instead of "[]" was the solution.

Last questions is, whether it is possible to add author and date of the latest posts.
avatarGuest
Sun 26 Apr 2015, 18:29
This is my latest topics box. Works like charm on phpBB3, no ugly default FM styled widget needed Razz, although you need the widget to be activated, but you can then simply hide it . This is what it looks like: http://prntscr.com/6ygmc1 Perhaps you can filter some ideas from it regarding the author ('auteur') and date/time ('datum/tijd') and Most Recent Topics ('Meest Recente Berichten'):


JS (placement in All the Pages):

Code:
[panda=js]$(function(){
var a ="";
    $('#right').css('display','none');
a = $('#right .module .inner').html();
if(a=== null){ return; };
$('.introduction').after('<div class="forabg"><div class="inner rctopicslist"><span class="corners-top"></span><ul class="topiclist"><li class="header"><dl class="icon"><dd class="rctoptitle"><div class="table-title"><h2>Meest Recente Berichten</h2></div></dd><dd class="rctoptime"><span>Datum/Tijd</span></dd><dd  class="rctopauthor"><span>Auteur</span></dd></dl></li></ul></div></div>');
a = a.replace(/<a href="\/t(.*)<\/a><br>/g,'<div id="topicc"><span id="rctitle"><a href="\/t$1</a></span>').replace(/<a href="\/u(.*)\/a>/g,'<span id="author"><a href="/u$1/a></span><span id="thedate">').replace(/<br><br>/g,'</span></div>');
$('#right .module .inner').html(a);
$('.module .inner #topicc').each(function(){
var   l = $(this).find('#rctitle').html();
var   m = $(this).find('#author').html();
var   n = $(this).find('#thedate').html();
   $('.rctopicslist').append('<ul class="topiclist rcforums"><li class="rcrow"><dl class="icon"><dd class="rctoptitle"><div class="table-title"><h2>'+l+'</h2></div></dd><dd class="rctoptime"><span>'+n+'</span></dd><dd  class="rctopauthor"><span>'+m+'</span></dd></dl></li></ul>');
});
});


CSS:

Code:
[panda=css]/*----------- RECENT TOPICS ----------------------------------*/
.rcforums{background-color: #EEEEE9;text-align:center;}
.rctoptitle{width:50%;text-align:left;}
.rctoptime{width:35%;text-align:left;}
.rctopauthor{width:10%;text-align:left;}
.rcrow {height: 18px;border-bottom: 1px solid #F3F3EE;border-top: 1px solid #F3F3EE;}
.rctopicslist .table-title h2{/font-weight:bold!important/;padding-left: 10px }
.rctopicslist .rctoptitle a{font-weight:bold!important;}
#container,#content,#main {float:none !important; margin:0px !important;}


Widget config:
http://prntscr.com/6ygrba

Hope it will help you.

Samantha.
avatarSchiggysboard
Status : No status yet...

Posts : 145
Join date : 2012-01-08
Sun 26 Apr 2015, 19:30
Thank you Samantha!
Tomorrow I will have more time, then I'm going to test it and report about the results.
avatarSchiggysboard
Status : No status yet...

Posts : 145
Join date : 2012-01-08
Mon 27 Apr 2015, 13:11
Ok, I tried to use yours with filtering some ideas from it, but it didn't work. thAnyway thank you. Smile

It would be the best, if someone will check my actual code (above) and will add the missing lines for adding author and date. :/
Does anybody has an idea for it? I would be very grateful!
avatarGuest
Mon 27 Apr 2015, 13:23
No worries, that's fine and I'm sorry. I'm no good JS programmer, but I love CSS. Thanks for having a go at it, anytime. You might have copied the code straight off, but that won't work. I'll let you to be at the claws of real programmers on this if you don't mind. If you need advice on your styling, you can contact me anytime. I'm pleased to see you on Avacweb as a member.

Since it's King's Day in The Netherlands, we'll be off for now and hit the city for an hour or two. Enjoy your day! Smile

Samantha.

Sponsored content