1 (edited by binomine 2005-02-11 07:00)

Topic: yanyan News version 0.0.1 for punBB 1.2.1

Hi,

I wanted to create a simple php interface for newspages and blogs using the punBB forum software.

It's not a newspage outright, it's simply an Interface between the forum software and your blog / newspage.  However, I'm going to attempt to make sure the outside of the Interface stays the same between different versions of punBB, so you won't lose your newpage between upgrades of punBB.  (of course, give me a week between punBB releases to allow me to fix things)


Then there are several class variables owned by yanyan

var $gNumComments; - Number of replies / comments in a post
var $gTextPost - the text;
var $gDate - the date;
var $gTime - the time;
var $gTextCommentURL - A URL to the post's forum ;
var $gNumPosts - Number of posts in a forum;
var $gPosterName - name of the poster;
var $gTopic - topic of the post;

To access these, we must first include this code.

//Init pun.
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';

require_once './yanyan.php';
$yan = new yanyan($db);

Then we need to initalize yanyan

$yan->getAllPosts('3');

Where '3' is the forum of this example.  '-1' if you'd like to obtain every post in your database.

This also populates gNumPosts, so you know how many posts we're dealing with.

We can then use one of two  functions

function getPost($postNumber)

GetPost populates every global variable

function getTitle($postNumber)

Get title populates
gNumComments
gCommentURL
gTopic
gPosterName.

This is if you want a simple list of topics instead of an entire post.   This function does not use a mysql query, which makes it ideal to sort by catagories.   You can use usernames as catagories or place a special character in the title and eliminate it on view. 

Now, you just access these class variables to produce your webpage.

Any questions can be placed here.  I accept guest logins for that forum only.
A quick test of the software.
The file and the test file

A quick view of test shows you everything.

for($ii = 0; $ii < $yan->gNumPosts; $ii++)
{
  $yan->getTitle($ii);
  echo "<h1>" . $yan->gTopic . "</h1><br>";
  echo $yan->gNumComments . "<br>";
  echo '<A href="'. $yan->gTextCommentURL . '">Text Comment</a><br>';
  echo $yan->gPosterName. "<br><hr>";
}

This code demonstrates getTitle, it gets the title of every post in a forum(selected by getAllTitle) and displays them, poorly.

Todo:
- canView() will oneday be used to make a friends only news forum capability by using punBB's own login system.   I just need to experiment with $user
- smiley support.  I have find the function to enable smiley support.  I'm sure someone will clue me in.
- make a user selectable date instead of the standard American date I choose.

Re: yanyan News version 0.0.1 for punBB 1.2.1

OUTSTANDING! good work. one step closer to a full blown cms based on punbb.

~James
FluxBB - Less is more