Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2010-09-23 11:22:09

dkoper
New member
Registered: 2010-04-19
Posts: 8

Linker plugin link to database

Hi,

Can someone help me to alter the scan.php file located in xinha/plugins/Linker.

I'm trying to list links I get from a mysql database. As far as I can see I need to alter the function scan to connect to the database, get the page name and id and return it in a kind of format linker.js can read.

I've tried this but it throws errors:

function scan($dir, $durl = ''){
  $files = array();
  $dir = realpath($dir);
  require_once(realpath(dirname(__FILE__) . '/../../../../php/config.php'));
  mysql_connect(DB_HOST,DB_LOGIN,DB_PASS);
  mysql_select_db(DB_NAME);
  $sql = "SELECT * FROM page";
  $result = mysql_query($sql) or die($sql."\n".mysql_error());
  while ($record = mysql_fetch_object($result)) {
   $id = $record->page_id;
   $title = $record->page_name_nl;
   $files[] = array('url'=>$dir.'/index.php?pid='.$id);
  }
  return dirsort($files);
}

I want the user to click on a page name (from database) and the input field URL automatically gets filled with the url (http://www.mydomain.com/index.php?pid=9)


I've read http://xinha.webfactional.com/wiki/Linker and some other posts about this subject, but I couldn't find a solution to my problem.

Offline

#2 2010-09-23 20:04:22

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Linker plugin link to database

Forget about scan.php as it is, rewrite it from scratch to do what you want.

All your new scan.php has to do is produce something like this at a minimum

[
  {
     url:   'a.html',
     title: 'A Title'
  },

  {
     url:   'b.html',
     title: 'B Title'
  }
]

James Sleeman

Offline

#3 2010-09-24 17:04:58

dkoper
New member
Registered: 2010-04-19
Posts: 8

Re: Linker plugin link to database

Hi gogo,

That's surprisingly easy!! Works like a charm.

Thank you for the quick reply.

Offline

Board footer

Powered by FluxBB