2
I've written a custom module that takes a table that is stored within the XOOPS database but which has no admin interface, and formats it.
I update it by downloading a .csv file from another site and then using MS access push it back to the server via the mysql-odbc driver.
The module is fairly simple.
The index.php just does this:
require('header.php');
include_once XOOPS_ROOT_PATH."/modules/bslist/class/class.bslist.php";
// We must always set our main template before including the header
$xoopsOption['template_main'] = 'bslist_simple.html';
$bs_array = BsList::get_bs();
$bs_count = count($bs_array);
// Include the page header
require(XOOPS_ROOT_PATH.'/header.php');
$xoopsTpl->assign('bs_count', $bs_count);
$xoopsTpl->assign('bs_array', $bs_array);
// Include the page footer
require(XOOPS_ROOT_PATH.'/footer.php');
?>
The two class files look like this:
::::::::::::::
class/class.bslist.php
::::::::::::::
include_once "class.bsmember.php";
class BsList extends BsMember
{
function get_bs($limit=0, $start=0)
{
$db =& Database::getInstance();
$ret = array();
$sql = "SELECT * FROM ".$db->prefix("bslist");
$sql .= " ORDER BY LastName";
$result = $db->query($sql,intval($limit),intval($start));
while ( $myrow = $db->fetchArray($result) ) {
$ret[] = new BsMember($myrow);
}
return $ret;
}
}
?>
::::::::::::::
class/class.bsmember.php
::::::::::::::
class BsMember
{
var $MemberNumber;
var $LastName;
var $FirstName;
var $Nickname;
var $SpouseFirst;
var $Address1;
var $Address2;
var $Address3;
var $City;
var $State;
var $ZipPC;
var $Country;
var $Email;
var $Type;
var $SocietyExpiration;
var $ChapterExpiration;
var $HomePhone;
var $WorkPhone;
var $Fax;
var $YearsOfService;
var $BirthDate;
var $MenOfNote;
function BsMember ($ary)
{
$this->LastName = $ary["LastName"];
$this->FirstName = $ary["FirstName"];
$this->HomePhone = $ary["HomePhone"];
$this->WorkPhone = $ary["WorkPhone"];
$this->Email = $ary["Email"];
if ($this->HomePhone == "0--0") $this->HomePhone = "";
if ($this->WorkPhone == "0--0") $this->WorkPhone = "";
}
}
and the template looks like this:
<style>
.bslist td { padding: 2px 1ex 2px 1ex; }
style>
<table class="bslist" llspacing="0" cellpadding="0">
<tr class="head">
<td>Nametd>
<td>Home Phonetd>
<td>Work Phonetd>
<td>Emailtd>
tr>
<{section name=bs_mem loop=$bs_array}>
<tr class='<{cycle values="even,odd"}>'>
<td><{$bs_array[bs_mem]->LastName}>, <{$bs_array[bs_mem]->FirstName}>td>
<td><{$bs_array[bs_mem]->HomePhone}>td>
<td><{$bs_array[bs_mem]->WorkPhone}>td>
<{assign var="email2" value=$bs_array[bs_mem]->Email}>
<td><{if $email2}><{mailto address=$email2 encode="javascript"}><{/if}>td>
tr>
<{/section}>
table>