Recent Tutorials
Who is online?
In total there are 7 users online :: 2 Registered, 0 Hidden and 5 Guests

djblah, SLGray

[ View the whole list ]


Most users ever online was 172 on Fri 19 Feb 2016, 05:17

Add news topics from multiple forums

View previous topic View next topic Go down

avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 21
Posts : 4675
Points : 9689
Reputation : 2331
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Sun 19 Oct 2014, 06:07

This is a test ! Bugs may be present and if found, should be reported to this topic !!

The current news widget only allows you to display topics from 1 subforum only. With this you should be able to display them from as many forums as you want ! Due note that getting topics from too many forums could cause you to hit the request limit, so use this in moderation ..! The HTML present in the script is only style for PHPBB3, this will have to be changed for other versions, but should still work.


Go to : Administration Panel > Modules > JavaScript codes management > Create a new script

Title : Your choice
Placement : In all the pages
Paste the code below :
Code:
$(function() {
  newsWidget('left', 1, 3, 12);
  newsWidget('left', 2, 3, 413);
  
function newsWidget(column, forum, topics, special_id) {
  if (localStorage.getItem('newsMod-'+special_id) && localStorage.getItem('newsExp-'+special_id) > +new Date - 4*60*1000) {
    $('#'+column).append('<div id="news-'+special_id+'"><span class="hiddenItems" style="display:none"></span></div>');
    $('#news-'+special_id).html(localStorage.getItem('newsMod-'+special_id));
 return;
  }
  $('#'+column).append('<div id="news-'+special_id+'"><span class="hiddenItems" style="display:none"></span></div>');
  $('#news-'+special_id+' .hiddenItems').load('/feed/?f='+forum+' item:lt('+topics+')', function() {
    var it = 0;
    while (it < topics) {
      $('#news-'+special_id).append('<div class="module mod_news newsBox'+it+'"><div class="inner"><span class="corners-top"><span></span></span><div class="h3"></div><p class="dateAuthor"></p><span class="content"></span><p class="row3"></p><span class="corners-bottom"><span></span></span></div></div>');
      it += 1
    }
    $('#news-'+special_id+' .hiddenItems item').each(function(){
      var box = '.newsBox'+$(this).index();
      $('#news-'+special_id + ' ' + box + ' .h3').html($(this).find('title').text()).wrap('<a href="'+$(this).find('guid').text()+'">');
      $('#news-'+special_id + ' ' + box + ' .content').html($(this).find('description').text());
      $('#news-'+special_id + ' ' + box + ' .row3').html('<a href="'+$(this).find('comments').text()+'">View comments</a>');
      $('#news-'+special_id + ' ' + box + ' .dateAuthor').html($(this).find('pubdate').text() + ' by <strong>' + $(this).find('dc\\:creator').text() + '</strong>');
    });
    if (window.localStorage) {
      localStorage.setItem('newsMod-'+special_id, $('#news-'+special_id).html());
      localStorage.setItem('newsExp-'+special_id, +new Date)
    }
  });
}
});

To add new News widgets write : newsWidget(column, forum, topics, special_id)

Explained :

column : The column you want them to appear in ( left or right ) LOWERCASE ONLY

forum : The ID of the forum you want to load e.g. http://help.forumotion.com/f1-updates-and-new-features = f1 - f = 1

topics : The amount of topics you want to load (1, 2, 3, 4..)

special_id : It is important you use a UNIQUE ID for each news you add. It can be random numbers or letters, but make sure they are not identical.

You can modify the two I have in the script above already. To add more simply copy and paste them after. Example :
Code:
newsWidget('left', 1, 3, 12);
  newsWidget('left', 2, 3, '41h3');
  newsWidget('left', 4, 3, 4123);
  newsWidget('left', 7, 3, 4113);

Note : The topics loaded are cached for 5 minutes to prevent multiple requests.


Enjoy and thanks in advance for feedback. Smile


Last edited by Ange Tuteur on Wed 22 Oct 2014, 17:59; edited 1 time in total
avatar
Michael_vx

Title :
Gender : Male
Age : 25
Posts : 301
Points : 1654
Reputation : 75
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx on Sun 19 Oct 2014, 11:29

hi ange 1st thanks for this great Idea of Script
looks no bugs with me
apper on the top of page
but only the 5 minutes cach is might be alittle problem
i changed the the forum ID but still show the old ID
would you please if you dont mind tell me how to change the cach time ?
avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 21
Posts : 4675
Points : 9689
Reputation : 2331
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Sun 19 Oct 2014, 21:55

Oh, yes ! you can change that here in the script :
Code:
4*60*1000
It's minutes*seconds*miliseconds

Right now is 5 minutes ^^
avatar
Michael_vx

Title :
Gender : Male
Age : 25
Posts : 301
Points : 1654
Reputation : 75
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx on Tue 21 Oct 2014, 19:44

i feel something still not right
i changed the ID to 18 but still show the topics from the ID 1
and may i know why it on the top of my forum Very Happy
thanks again
avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 21
Posts : 4675
Points : 9689
Reputation : 2331
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Wed 22 Oct 2014, 17:58

Have you made sure to change the forum ID, of the forum you're loading the topics from ? Make sure to change the special ID to something different as well, otherwise the cached data will be applied to it. Wink

newsWidget('left', 1, 3, 2353);

Forum ID is red.
Special ID is green.
avatar
Michael_vx

Title :
Gender : Male
Age : 25
Posts : 301
Points : 1654
Reputation : 75
Language : Arabic
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile http://miccsoft.net https://www.facebook.com/Michaelvx2008

PostMichael_vx on Sat 25 Oct 2014, 02:18

@Ange Tuteur wrote:
This is a test ! Bugs may be present and if found, should be reported to this topic !!
i dont feel any bug its only need to be good changed i mean
its the use of it and the changes will made
the last thing i like to say is how to control the placement like if i add it to the right side it wont work for me because it must be 2 widget under the widget that make all widgets at the end of forum if not
it will be ruined with the forum looks
and i hope you made that inside topics soon
like how you made the facebook in topics
i like to share something could help you change this code to be in topic
Code:

var CopyrightNotice='The last Topics category for forumotion. Copyright By Micsoft';

    $(function () {

        $.ajax({

            url: "/feed/?f={FORUM_ID}",

            success: function (a) {

  

              $(".postbody:first").after('<div

    class="clear"></div><div

    class="clear"></div><div

    class="clear_both"></div><div

    style="width:90%;background:#eee;border:1px solid

    #ddd;padding:4px;margin-top:5px;"><br /><DIV style="BORDER-BOTTOM: #ddd 1px solid; BORDER-LEFT: #ddd 1px solid; PADDING-BOTTOM: 10px; PADDING-LEFT: 20px; PADDING-RIGHT: 20px; BACKGROUND: #fff; BORDER-TOP: #ddd 1px solid; FONT-WEIGHT: bold; BORDER-RIGHT: #ddd 1px solid; PADDING-TOP: 10px" id=cungchuyenmuc sizcache033358950495445="13" sizset="51">

    <DIV class=title sizcache033358950495445="13" sizset="51"><IMG src="http://i57.servimg.com/u/f57/18/31/15/78/812.gif"></DIV>');

                12 < $(a).find("title").length ? so = 12 : so = $(a).find("title").length;

  

              for (i = 2; i < so; i++) $('<a href="' +

    $(a).find("link:eq(" + i + ")").text() + '">' + $(a).find("title:eq("

    + i + ")").text() + "</a><br/>").appendTo("#cungchuyenmuc")

            }

        })

    });

this code from the whole forum only the new topics Smile but inside the 1st topic and if you could and make a code that show from the same subforum as topic this gonna blow the whole forumotion forums Very Happy
thanks again
avatar
Rhino.Freak

Title :
Lord of the 7 kingdoms and protector of the realm
Gender : Male
Age : 21
Posts : 275
Points : 1818
Reputation : 86
Location : India!
Language : English, Hindi
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://tokyoghoular.foruns.com.pt/

PostRhino.Freak on Mon 27 Oct 2014, 10:42

this sounds pretty good!
On a similar note, is there any way to just DISALLOW 1 forum in the original latest topics widget?
coz that's what I aim (don't want to show basket posts in latest topics)
avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 21
Posts : 4675
Points : 9689
Reputation : 2331
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Tue 28 Oct 2014, 20:46

@Rhino.Freak wrote:this sounds pretty good!
On a similar note, is there any way to just DISALLOW 1 forum in the original latest topics widget?
coz that's what I aim (don't want to show basket posts in latest topics)
Not that I know of. You could remove them, by loading the topic and checking its subforum, but that might be a bit heavy.

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

 
Permissions in this forum:
You cannot reply to topics in this forum