steve
unread,Aug 20, 2010, 9:02:50 AM8/20/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to devel-querypath
I'm trying out QP 2.1 to use the new abbr() option but I think this
version is causing a problem with templates.
The template documentation shows an example of filling a table. This
works just great in 2.0 but when I try it in 2.1 I get:
Warning: SplObjectStorage::attach() expects parameter 1 to be object,
null given in C:\wamp\www\cms\querypath\QueryPath.php on line 1206
Fatal error: Call to a member function createDocumentFragment() on a
non-object in C:\wamp\www\cms\querypath\QueryPath.php on line 1717
The simpler example of filling a list works fine in 2.1
Thanks, Steve.
Code:
<?php
require_once("QueryPath/QueryPath.php");
require_once("QueryPath/Extension/QPTPL.php");
// Define the template
$tpl = '<?xml version="1.0"?><table>
<tbody>
<tr class="header-row">
<th class="header1"/>
<th class="header2"/>
</tr>
<tr class="table-row">
<td class="cell1"></td>
<td class="cell2"></td>
</tr>
</tbody>
</table>';
// Define the data
$data['.header1'][] = 'Header One';
$data['.header2'][] = 'Header Two';
$data['.table-row'][] = array(
'.cell1' => 'Cell One',
'.cell2' => 'Cell Two',
);
$data['.table-row'][] = array(
'.cell1' => 'Cell Three',
'.cell2' => 'Cell Four',
);
$data['.table-row'][] = array(
'.cell1' => 'Cell Five',
'.cell2' => 'Cell Six',
);
// Merge the template and write out the results.
qp()->tpl($tpl, $data)->writeHTML();
?>