[pmwiki-users] PageLists of database contents
Ben Stallings
Ben at InterdependentWeb.com
Mon Oct 9 17:43:56 CDT 2006
Patrick R. Michaud wrote:
>> Second, if you try searching the Source group at
>> http://www.workscited.net/ben/Site/Search , it doesn't appear to search
>> page text variables... which was the whole point of putting the records
>> in that format. For example, search for $:firstname=Will. No dice,
>> although you can see by clicking the editing link above that record 12's
>> firstname is Will. Ideas?
>
> Not at the moment -- seems like it ought to work. What if
> you just use a page text variable directly in a page, as opposed
> to going through (:pagelist:) to get it -- does it correctly
> grab values of {$:firstname} for records in the Source group?
>
> I.e., does {Source.12$:firstname} work?
No, it doesn't. I think the problem is that although my DataStore
class's read method is able to fool the pagelist function, it's not
quite pageish enough to fool the page-text-variable function.
I tried editing (the virtual) Source.12 and saving it as an actual page:
this caused page-text-variables to start working immediately. I opened
the new page with a text editor and saw that it had a bunch of new
headers in addition to the text= one that my read method created. I
systematically deleted these until I found that deleting the first line --
version=pmwiki-2.2.0-beta14 ordered=1 urlencoded=1
-- caused page text variables to stop working.
So I modified the read method to generate that line as follows:
$page['version'] = "$Version ordered=1 urlencoded=1";
No dice. Tried dividing it up into three variables:
$page['version'] = $Version;
$page['ordered'] = 1;
$page['urlencoded'] = 1;
Still nothing. Tried setting ordered=0 and urlencoded=0. Nope. Tried
replacing the \n linebreaks with %0a and toggling urlencoded again.
Didn't help.
I'm sure it's something very simple... I need to set $JeNeCestQuoi=1,
perhaps. So for your debugging pleasure, here's the read method of the
pre-alpha DataStore class:
function read($pagename, $since=0) {
global $DQdb, $DQglobals, $Version;
$tables = strtolower(FmtPageName('$Group',$pagename));
if ($tables != $this->group) return;
$display = strtolower(FmtPageName('$Name',$pagename));
if ((!$display) or ($display == $tables)) {
$page['text'] = "(:pagelist group=".ucwords($tables).":)";
return $page;
}
list($primary) = $DQdb->MetaPrimaryKeys($tables);
$sql = "SELECT * FROM $tables WHERE $primary = $display";
if (!$rs = $DQdb->Execute($sql)) return;
### here's the troublesome bit ###
$page['version'] = "$Version ordered=1 urlencoded=1";
$page['text'] = "(:title $tables record #$display:)\n";
if ($data = $rs->FetchRow()) {
foreach ($data as $key => $value) {
if (!in_array("$tables.$key",$DQglobals['offLimits'])) {
$page['text'] .= "$key:$value\n\n";
}
}
}
return @$page;
}
First person to solve the puzzle gets a week's supply of Je Ne C'est
Quoi! Thanks in advance. --Ben S.
More information about the pmwiki-users
mailing list