Author
Mads Baggesen studies Computer Science at Aarhus University.
E-mail
FundaLinks Guide
Published on Friday, January 30 2004
Written by Mads Baggesen and translated by Brian Jørgensen
In this article I'll introduce how to use the link module fundaLinks and how I use it. I'll present the code I'm using so other users can benefit from it.
The appearance can to a high degree be changed using CSS, since most of the output is placed in a simple table structure.
Adding a category of links
First we have to add a number of categories that your links can be categorised into. We do this by logging into Fundanemt and opening the link module.
A small window will appear, where you select which category to add links to or if you want to add or remove a category.
Adding a new link
The list of all we are presented with after having opened a category is all the links in the given category and we is now ready to add links to our database.
This is done by clicking on the third button in the toolbar with a small plus (+) in the lower right corner.
In the dialog window which has opened you enter the relevant informations for the link and clicks on the "Create link" button to add the link to the list.
Frontend code to put on your page
When you have created the page on which you want to list the link archive, insert the following piece of PHP code in a PHP element on that page.
Link archive - frontend code
<?php
// Make parser object accessible
global $parser;
if(!isset($_GET["showCat"]) OR empty($_GET["showCat"])) {
// Set active table to the link category table
$parser->D->dbSetTable(DB_PREFIX."linkscat");
$res = $parser->D->dbQuery("SELECT * FROM ".$parser->D->table);
print ' <ul>';
while($s = $parser->D->dbFetchArray($res)) {
print '<li>
<a href=\" '.id2url($parser->ID,$parser->lang,$_SERVER[PHP_SELF],$parser->tlid,$parser->D,$parser->parent).(URL_TYPE==0 ? "&" : "?").'showCat='.$s[CATEGORY].'\"></li>';
} // while fetch
print '</ul><br>';
print '
<center>
<table class="fundaLinks" cellspacing="5px" cellpadding="5px">
';
while($p = $parser->D->dbFetchArray($res)) {
print '
<tr>
<td class="fundaLinksHeader" colspan="2">
</td>
</tr>
';
// Set active table to the link content table
$parser->D->dbSetTable(DB_PREFIX."linkscon");
$res2 = $parser->D->dbQuery("SELECT * FROM ".$parser->D->table." WHERE SEKTION=\"$p[CATEGORY]\"");
while($u = $parser->D->dbFetchArray($res2)) {
print '
<tr valign="top">
<td class="fundaLinksLinkName">
<p><strong><a class="fundaLink" href="/fundanemt/modules/fundaLinks/showlink.php?linkid='.$u["ID"].'" target="_blank">
'.$parser->convertContent($u["OVERSKRIFT"]).'</a></strong> (Hits:'. $u["HITS"].')
</td>
<td class=\"fundaLinksDescription\">
'.$parser->convertContent($u[TEKSTKORT]).'
</td>
</tr>
';
}
}
print '
</td>
</tr>
</table>
</center>
';
} else { // showCat is set
print '
<center>
<table class="fundaLinks" cellspacing="5px" cellpadding="5px">
';
print '
<tr>
<td class="fundaLinksHeader" colspan="2">
</td>
</tr>
';
// Set active table to the link content table
$parser->D->dbSetTable(DB_PREFIX."linkscon");
$res = $parser->D->dbQuery("SELECT * FROM ".$parser->D->table." WHERE SEKTION=\"".$_GET["showCat"]."\"");
while($u = $parser->D->dbFetchArray($res)) {
print '
<tr valign="top">
<td class="fundaLinksLinkName">
<p><strong><a class="fundaLink" href="/fundanemt/modules/fundaLinks/showlink.php?linkid='.$u["ID"].'" target="_blank">
'.$parser->convertContent($u["OVERSKRIFT"]).'</a></strong> (Hits:'. $u["HITS"].')
</td>
<td class=\"fundaLinksDescription\">
'.$parser->convertContent($u[TEKSTKORT]).'
</td>
</tr>
';
}
print '
</td>
</tr>
</table>
</center>
';
} // else
?>
CSS - Change design
The only thing missing is some CSS to define the design for how the links and categoris should be presented.
The colors might have to be changed to fit into your page design.
Link archive - frontend stylesheet
/*
* fundaLinks CSS
*/
table.fundaLinks {
width: 70%;
text-align: center;
}
td.fundaLinksHeader {
background-color: #003366;
border: 1px #000000 dashed;
}
td.fundaLinksDescription {
border-top: 1px #FFFFFF dashed;
border-bottom: 1px #FFFFFF dashed;
}
td.fundaLinksLinkName {
width: 30%;
vertical-align: middle;
}
a.fundaLink {
text-decoration:underline;
font-size:14pt;
font-family:Verdana, sans-serif;
color:#003366;
}The end
Thats all I wanted to write for now.
If you have any comments or suggestions feel free to contact me at mads [at] baggesen.net or visit #Fundanemt at irc.freenode.org where I'm called IzNo.
