Links Archive

From FundaWiki

Jump to: navigation, search

If you want a link archive on one of your pages, open the page edit window, double click on one of your current pages or create a new one. Select the option to put PHP code on your page and copy/paste the code below. Dont forget to save your changes. I hope you get your link archive up and running a little bit faster than I did.


This code does not count the number of hits to each of the links.

/* Uncomment if you want to specify the category manually

   otherwise the current page name will be used */

//$linkcategory = "mylinks";

if(!isset($linkcategory)){

  /* The category is the current page name */
  $this->D->dbSetTable(DB_PREFIX . "webindex");
  $linkcategory = $this->D->dbGetFieldN("TITLE", "ID", $this->ID);

}

$res = $this->D->dbQuery("SELECT CATEGORY FROM " . DB_PREFIX . "linkscat 
       WHERE CATEGORY = '$linkcategory'"); $entry = $this->D->dbFetchArray($res);

$this->D->dbSetTable(DB_PREFIX . "linkscon");

$res = $this->D->dbQuery("SELECT * FROM " . DB_PREFIX . "linkscon," . DB_PREFIX . "linkscat 
        WHERE " . DB_PREFIX . "linkscat.CATEGORY ='".$linkcategory."' 
        AND " . DB_PREFIX . "linkscat.CATEGORY = " . DB_PREFIX . "linkscon.SEKTION ORDER BY TIMESTAMP DESC");

setlocale(LC_TIME,"da_DK"); while ($entry = $this->D->dbFetchArray($res)) {

  /* Prints the links */
  echo "<p><a href=\"".$entry["LINK"]."\">".$entry["OVERSKRIFT"]."</a><br>";
  echo "<i>".$entry["TEKSTKORT"]."</i><br />";
  if($entry["EMAIL"]){
    echo "Postet af <a href=\"mailto:".$entry["EMAIL"]."\">".$entry["FORFATTER"]."</a>";
  } else {
    echo "Postet af ".$entry["FORFATTER"];
  }
  echo "</p>";

}
Personal tools