MNN News

Manages technical infrastructure for the board and website; make administrative requests here

Moderator: Erik Mortis

Post Reply
User avatar
Ari Rahikkala
Posts: 4326
Joined: Sun Jan 21, 2001 12:56 pm
Contact:

MNN News

Post by Ari Rahikkala »

Well, Iain gave me the idea, so I figured I might give it a try. I quickly hacked up a display of the MNN News And Comment feed. Updated hourly. I'm not particularly happy with its positioning on the page though... I keep confusing it with the forum-related links above it... but didn't really have any better ideas where to put it. But maybe someone else does?
No-one should be without a parasol, Sirocco.

User avatar
Jonas
Posts: 5334
Joined: Mon Feb 19, 2007 9:53 am

Re: MNN News

Post by Jonas »

It isn't bad! But maybe next to the banner (at the left to avoid confusion). :document
From a distance I'm concerned about the rampant lawyerism manifesting itself in Shireroth currently. A simple Kaiserial slap on the wrist or censure by the community should suffice. - Jacobus Loki
Can't you see? I'm crazy! :tomcutterhamonfire :smashy

Iskander Mirkdale
Posts: 270
Joined: Wed Jan 31, 2007 3:11 pm

Re: MNN News

Post by Iskander Mirkdale »

Ooh, thank you. Yes the positioning question is a good one, as the Malarbox does give Shireroth a unique header layout. I don't know if a horizontal ticker of sorts would look better, but that's what I had envisaged would work reasonably well with most forum header layouts.
The Earl of Eliria and Utasia
MNN, MMR, AFV, II

Erik Mortis
Posts: 7238
Joined: Thu Oct 02, 2003 10:37 pm
Location: County of Monty Crisco
Contact:

Re: MNN News

Post by Erik Mortis »

Could we add Harvey's thing?

User avatar
Harvey Steffke
Posts: 1599
Joined: Sat Feb 23, 2008 9:28 pm

Re: MNN News

Post by Harvey Steffke »

Harvey's thing is with the rest of the links "Calendar - Wiki - Bank - Aurora - MCS - Chat"

Also, the MNN feed will display my stories when I write something current. In fact, it's displaying one of them now.

Erik Mortis
Posts: 7238
Joined: Thu Oct 02, 2003 10:37 pm
Location: County of Monty Crisco
Contact:

Re: MNN News

Post by Erik Mortis »

Well then.. Goodo.

User avatar
Jonas
Posts: 5334
Joined: Mon Feb 19, 2007 9:53 am

Re: MNN News

Post by Jonas »

Ari, can you send me the code of the MNN Newsbox? Batavia wants to use it. :angel
From a distance I'm concerned about the rampant lawyerism manifesting itself in Shireroth currently. A simple Kaiserial slap on the wrist or censure by the community should suffice. - Jacobus Loki
Can't you see? I'm crazy! :tomcutterhamonfire :smashy

User avatar
Ari Rahikkala
Posts: 4326
Joined: Sun Jan 21, 2001 12:56 pm
Contact:

Re: MNN News

Post by Ari Rahikkala »

To be honest it's one of those things that consist of a lot of glue and little complicated code, so there's going to be almost as much work in integrating it as there was in writing it in the first place. But if you really want to know...

First, there's a script, called snarf_mnn.php, placed in my home directory at my hosting account:

Code: Select all

<?php

$xml = simplexml_load_file ("http://www.xfruits.com/micronations/?id=67998");

if (!$xml)
	die ("Couldn't fetch MNN RSS XML");

$str = "<ul>";

$n = 5;

for ($i = 0; $i < $n && $xml->channel->item[$i]; $i++) {
  $str .= "<li><a href=\"" . $xml->channel->item[$i]->link . "\">" . $xml->channel->item[$i]->title . "</a></li>";
}

$str .= "</ul>";

file_put_contents ("public_html/shireroth/forum/mnn_update.txt", $str);

?>
Very straightforward as you can see. Just fetches the micronations.net RSS, and outputs a list of the first five items. There's a reason it's called Really Simple Syndication, you know. Also in the straightforwardness department it'll break if there are less than five items in the stream, but I'm assuming that will never happen :p.

It's called hourly from cron - how to call things from cron is completely host-dependent, for instance on Bluehost there's a "cron jobs" option in the control panel, and the program for running PHP scripts is called php5-cli. But you don't really have a choice other than to know how to run scheduled jobs if you want to make any use of this script.

Anyways, as you can see it creates a file named mnn_update.txt, conveniently right there in the forum directory. This file is then read in includes/functions.php, in the function page_header():

Code: Select all

$mnn_text = file_get_contents ($phpbb_root_path . "mnn_update.txt");
^ goes anywhere in that function before the big assign_vars block

Code: Select all

'MNN' => $mnn_text,
^ goes inside the big assign_vars block... come to think of it you don't even need the variable there...

Anyways, now the template variable "MNN" contains the list of links to the newest news at the MNN. For instance in the Malarbor template it's added in as simply as putting in this in the appropriate place:

Code: Select all

            <div style="border: 2px solid black; background-color: #000066; margin-top: 5em;">
            <center>MNN news</center>
              {MNN}
            </div>


So, yeah, basically. In so many words, if you already are competent know your php and phpBB and how to configure stuff at your webhost, most of this code is not of much help since you already know how to write it, and if you aren't, you won't be able to integrate it. So it's not really all that useful altogether. But I figured that the best way of explaining why you don't really want to see the code would be to show the code and explain why you didn't really want to see it :p
No-one should be without a parasol, Sirocco.

Post Reply

Return to “Ministry of the Interior”

Who is online

Users browsing this forum: No registered users and 3 guests