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
News On Your Forum
Topic Started: Jul 14 2016, 11:05 PM (2,480 Views)
Skyon Archer
Member Avatar
Member
[ *  *  *  * ]
Code Name: News On Your Forum
What the code does: Integrates Top Stories or specific news headlines on your forum
How to use the code: Admin CP > Board Template > Above the Copyright. There are three edits available, continue reading....
How to install the code: See below
Extra notes:
If you do not enter any information for the variables, the script will automatically display ten Top Stories.

Code:
 
<script type="text/javascript">
// BEGIN: ENTER YOUR NEWS TOPIC, ID/CLASS WHERE YOU WANT NEWS DISPLAYED, NUMBER OF DISPLAYED STORIES

var newsTopic = 'YOUR-NEWS-TOPIC';
var newsCount = '10'; // default is 10, maximum is 15
var whereGoes = '#main'; // where does it go?

// END: THAT'S IT, SAVE "ABOVE THE COPYRIGHT"

if(whereGoes === ''){ var whereGoes = '#main'; }
$.ajax({ type: "GET", url: "http://newsheadquarter.com/remote.php?f="+newsTopic+"&c="+newsCount, success: function (mystring) {
$(whereGoes).append(mystring);
}
});
</script>


Say you are running a Harry Potter forum. Maybe you'd like to display some headlines about good ol' Harry. In that case, you would replace YOUR-NEWS-TOPIC with Harry Potter. You would then be presented with news articles about Harry Potter:

Posted Image

Or maybe you want to display Call of Duty or Photoshop news:

Posted Image
Posted Image

Now, this code will automatically append the news to the bottom of the board. If you want it to be somewhere else, you simply put the ID or CLASS of that selector in the variable of whereGoes. For instance, if you want it displayed at the top of your forum, you may put a division with an ID of "news" in the "Above the Board" section of your ACP. As such, you would put #news:

Code:
 
var whereGoes = '#news';


Remember, if you simply make the variables blank, it will show ten Top Stories below your forum.

Questions/Complaints? Let me know! For a live preview, visit http://s15.zetaboards.com/NewsOnForum/index/
Offline Profile Quote Post Goto Top
 
Helena
Member Avatar
M is for Mod

That is a brilliant option to be able to run theme-specific stories so efficiently.

I did that on a former forum by using RSS feeds, but content was really at the mercy of single feed sources. This seems to be more of an aggregator-type sweep which is so much more comprehensive.

Attractive format as well. I'm sure we'll be seeing this on boards around the network.
Offline Profile Quote Post Goto Top
 
DaPizzaMan
Member Avatar
#TeamSupport

Broken "News Image": http://newsheadquarter.com/img/s//1.jpg

Not sure if that's something wrong with the code or the image, but yeah. :P
Attached to this post:
Attachments: Screen_Shot_2016_07_15_at_4.34.03_PM.png (211.38 KB)
Offline Profile Quote Post Goto Top
 
Skyon Archer
Member Avatar
Member
[ *  *  *  * ]
Should be all fixed now. Thanks for pointing it out :)
Offline Profile Quote Post Goto Top
 
polocolo
Member Avatar
Member
[ *  *  * ]
Can i post the news on a webpage?
Offline Profile Quote Post Goto Top
 
Skyon Archer
Member Avatar
Member
[ *  *  *  * ]
polocolo
Jul 15 2016, 06:44 PM
Can i post the news on a webpage?
Read my comments below:

Code:
 
<script type="text/javascript">
// News on Forum

if(window.location.href.indexOf("/pages/") > -1) {
// THIS IS IF YOU HAVE A WEBSITE MAKER PAGE SHOWING NEWS
var newsTopic = 'automotive'; // NEWS TOPIC
var newsCount = '10'; // default is 10
var whereGoes = '#newsbox'; // ID/CLASS WHERE YOU WANT DISPLAYED ON WEBSITE MAKER PAGE
}else{
// THIS IS FOR THE REST OF THE FORUM
var newsTopic = 'donald trump'; // NEWS TOPIC
var newsCount = '5'; // default is 10
var whereGoes = '#main'; // ID/CLASS WHERE YOU WANT DISPLAYED
}

// END: THAT'S IT, SAVE "ABOVE THE COPYRIGHT"

if(whereGoes === ''){ var whereGoes = '#main'; }
$.ajax({ type: "GET", url: "http://newsheadquarter.com/remote.php?f="+newsTopic+"&c="+newsCount, success: function (mystring) {
$(whereGoes).append(mystring);
}
});
</script>


You can have news either displayed on site anywhere you want or on a website maker page. The default setting is to have the news appended to the division with an ID of main, which makes the news appear at the bottom of the site on all pages.

If you want the news to only be displayed on a website maker page, you need to create a website maker page and add a division with a specific ID. In the code above I added a division with an ID of newsbox. So, in a website maker page, you need to put this:

Code:
 
<div id="newsbox"></div>

Example: http://s15.zetaboards.com/NewsOnForum/pages/news/

If you need further assistance, let me know.
Edited by Skyon Archer, Jul 15 2016, 08:34 PM.
Offline Profile Quote Post Goto Top
 
Harvyy
Member Avatar
Member
[ *  *  * ]
Woah! this code is awesome. How do I add this to a forum section? I tried by replacing #main with the forum_id but it didn't work. I copied and paste this code to the section's: http://image.prntscr.com/image/deecb71bdef8410483ecba782a22dabb.png so it news will display on the top but this happen: http://image.prntscr.com/image/aadb11f7c9404a459af4fa01c9865963.png

Is it possible for you to make this code work in the forum rules box?
Offline Profile Quote Post Goto Top
 
polocolo
Member Avatar
Member
[ *  *  * ]
Awesome! Working perfectly. Thank you so much for sharing such a great code!


EDIT:

1. Although I put 15 but the page only gives me 10 news ( http://wallacehuoforum.info/pages/wallace_huo/ )

2. How do I open the page as an additional page (not replacing the index page I'm viewing).


Thanks!
Edited by polocolo, Jul 16 2016, 03:09 PM.
Offline Profile Quote Post Goto Top
 
Skyon Archer
Member Avatar
Member
[ *  *  *  * ]
Harvvy. Forum Rules do not allow html in them. As such, you can not (easily) input the news in a forum. As such, see below. I've customized the code to display in forum fules:

Quote:
 
THIS IS IF YOU ARE DISPLAYING IN FORUM RULES - You need to go to section manager, edit settings of forum you want to display news in. At bottom of settings, make 'Rules Display Options' set to "Show full rules". Then type in the 'Rules Title' a name for your displayed news. This goes below in the code. That's it. Put nothing in the 'Forum Rules' section. Click on the button at the bottom "Edit forum". Then put the title you used in 'Rules Title' down below in the code.....


Code:
 

<script type="text/javascript">
// THIS IS IF YOU ARE DISPLAYING NEWS IN FORUM RULES
// THIS CODE GOES IN THE BELOW THE BOARD SECTION OF BOARD TEMPLATE

if (/forum/.test(window.location.href)){
var newsTopic = 'pokemon'; // CHANGE NEWS TOPIC HERE
var newsCount = '5'; // NUMBER OF STORIES TO DISPLAY: default is 10

$.ajax({ type: "GET", url: "http://newsheadquarter.com/remote.php?f="+newsTopic+"&c="+newsCount, success: function (mystring) {

//PUT TITLE IN HERE BETWEEN DOUBLE QUOTES
$('.meta_box h3:contains("TODAYS NEWS")').after(mystring);

}
});
}
</script>





polocolo
Jul 16 2016, 02:03 PM

1. Although I put 15 but the page only gives me 10 news ( http://wallacehuoforum.info/pages/wallace_huo/ )

2. How do I open the page as an additional page (not replacing the index page I'm viewing).


Thanks!

polocolo, I looked at the code as inserted on your site, and it looks to be working well. I really don't know why it's not showing more than 10 stories for you, when you clearly are asking for 15. I observed the same issue on my test site. It will always show less than 10, but seldom more than 10.

As for opening in a new window, when I click on a link on your site I'm redirected to a new tab/window, so it is working as intended for me.

Sorry about this issues. I'll go on my server and see if I can figure out what setting I may have put that may be causing the reduced number of stories issue. In the meantime, keep your setting at 15 and may be it will suddenly start working for you :r
Edited by Skyon Archer, Jul 16 2016, 09:56 PM.
Offline Profile Quote Post Goto Top
 
polocolo
Member Avatar
Member
[ *  *  * ]
1. Thanks. I will keep it at 15. Thanks for taking the time to research the issue.

2. I have put a link of the news on my submenu bar http://wallacehuoforum.info/index/ . It doesn't open up a new tap.

EDIT:

Found the code: <a target="_blank" href="http://your_url_here.html">Link</a> for my second question.

Edited by polocolo, Jul 18 2016, 09:57 AM.
Offline Profile Quote Post Goto Top
 
Harvyy
Member Avatar
Member
[ *  *  * ]
The forum rules version is not working for me. Here is proof i enter the code: http://image.prntscr.com/image/fabca799f7224aa4819772c03235807d.png

I even deleted all other scripts to make sure it was not conflicting with it.

Then I change the rule title only like you said but still no luck:
http://image.prntscr.com/image/a6e1f1d878ac4d15a58908ed29420b83.png

I see how it works on your test forum, it's at the bottom, is it possible to make it appear at the top, underneath the rule title since you can't put it in the rules. Like so: http://image.prntscr.com/image/18cd367a14414d12a9cd01cbc953aa4c.png
Offline Profile Quote Post Goto Top
 
Skyon Archer
Member Avatar
Member
[ *  *  *  * ]
Harvvy, you did not change the RULES TITLE in the code.

Quote:
 
//PUT TITLE IN HERE BETWEEN DOUBLE QUOTES
$('.meta_box h3:contains("TODAYS NEWS")').after(mystring);


You've created Rules with the title of "Pokemon" but in the code you left it as"TODAYS NEWS".

Your code should look like this:
Code:
 
<script type="text/javascript">
// THIS IS IF YOU ARE DISPLAYING NEWS IN FORUM RULES
// THIS CODE GOES IN THE BELOW THE BOARD SECTION OF BOARD TEMPLATE

if (/forum/.test(window.location.href)){
var newsTopic = 'pokemon'; // CHANGE NEWS TOPIC HERE
var newsCount = '5'; // NUMBER OF STORIES TO DISPLAY: default is 10

$.ajax({ type: "GET", url: "http://newsheadquarter.com/remote.php?f="+newsTopic+"&c="+newsCount, success: function (mystring) {

//PUT TITLE IN HERE BETWEEN DOUBLE QUOTES
$('.meta_box h3:contains("Pokemon")').after(mystring);

}
});
}
</script>


I assure you, I have tested this code and it does work. The code is currently not on the Preview site as I wrote it specifically for you.
Offline Profile Quote Post Goto Top
 
polocolo
Member Avatar
Member
[ *  *  * ]
Do the news refresh when new related news come up on the internet?
Offline Profile Quote Post Goto Top
 
Skyon Archer
Member Avatar
Member
[ *  *  *  * ]
When the page is refreshed, the script looks for new news. So yes, the news updates automatically upon page refresh.
Offline Profile Quote Post Goto Top
 
Harvyy
Member Avatar
Member
[ *  *  * ]
Wow i feel silly now. Thanks, appreciate the code.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · ZetaBoards Codes & Modifications · Next Topic »
Add Reply