[PHPTAL] tal:repeat and mysqli_query
Hi, These two files will output the number of records (2) from a MySQL database but not the record data. Can anyone suggest what I'm doing wrong? Thanks, Chris results = $results; $template->records = $records; try { echo $template->execute(); } catch (Exception $e){ echo $e; } ?> Articles Records id entitled located_at written_by created_on updated_on words_long text replaced by result text replaced by result text replaced by result text replaced by result text replaced by result text replaced by result text replaced by result ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
[PHPTAL] Prefilter fails
Hi everyone, Very impressed by PHPTAL and define-macro and define-slot work well for me. However now trying to use the Prefilter (as in the manual at http://phptal.motion-twin.com/manual/en/split/ar06s04.html ). The code suggested (below) causes my PHP v5 to die. I thought PHP's "implements" only worked with "interface" but the PHPTAL.php 1_1_15 doesn't use "interface" anywhere, so this is never going to work. Have I misunderstood or is the manual out of date on this point? Thanks, Chris ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] tal:repeat and mysqli_query
php...@jakeman.plus.com wrote: Hi, These two files will output the number of records (2) from a MySQL database but not the record data. Can anyone suggest what I'm doing wrong? Thanks, Chris results = $results; $template->records = $records; try { echo $template->execute(); } catch (Exception $e){ echo $e; } ?> Articles Records id entitled located_at written_by created_on updated_on words_long text replaced by result text replaced by result text replaced by result text replaced by result text replaced by result text replaced by result text replaced by result first of all, the value returned by "mysqli_query" is a resource, not a resultset. You have to use one of "fetch" functions to get a resultset. fetch function gives you one row at a time, so you could create an array of these rows and in phptal template use "repeat:" functionality like this: text replaced by result text replaced by result text replaced by result text replaced by result text replaced by result text replaced by result text replaced by result (given "result" is an array of fetched rows) hth, kaaposc ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Prefilter fails
On 19-02-2009 at 07:59:53 wrote: I thought PHP's "implements" only worked with "interface" but the PHPTAL.php 1_1_15 doesn't use "interface" anywhere, so this is never going to work. Have I misunderstood or is the manual out of date on this point? Sorry, manual fails to mention that you need to add require_once 'PHPTAL/Filter.php'; to your code. I'll make that unnecessary in next version of PHPTAL. -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
RE: [PHPTAL] tal:repeat and mysqli_query
Hi kaaposc, > first of all, the value returned by "mysqli_query" is a > resource, not a resultset. You have to use one of "fetch" > functions to get a resultset. > fetch function gives you one row at a time, so you could > create an array of these rows and in phptal template use > "repeat:" functionality like this: > > > text replaced by result > text replaced by result > text replaced by result > text replaced by result > text replaced by result > text replaced by result > text replaced by result > > > (given "result" is an array of fetched rows) > > hth, > kaaposc Yes, it did help. No changes needed to the HTML, but the PHP now works using mysqli_fetch_array() and array_push(): items = $items; $template->records = $records; try { echo $template->execute(); } catch (Exception $e){ echo $e; } ?> Many thanks, Chris ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
[PHPTAL] Posted messages don't appear - warning
Hi, Please note, if you post a message from an email address that is different from the one you used to register with the mailing list, then your message will be ignored. I guess this is a basic security measure to avoid spam pollution, but it caught me out and I thought I was pretty Internet-aware. Not suggesting that anything should change; just wanted to publish a message that might help another would-be poster someday. Bye for now, Chris ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
RE: [PHPTAL] Prefilter fails
Hi, > Sorry, manual fails to mention that you need to add > > require_once 'PHPTAL/Filter.php'; > > to your code. I'll make that unnecessary in next version of PHPTAL. > > regards, Kornel Thanks, Kornel. Added that and PHP no longer dies. But I still can't get the Prefilter to change the output even if I totally replace the source using: filtered content"; } } $tpl = new PHPTAL('mytemplate.html'); $tpl->setPreFilter(new MyPreFilter()); echo $tpl->execute(); ?> It would really help if I can see a sample that's known to work. Thanks, Chris ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Prefilter fails
On 19-02-2009 at 16:28:35 wrote: Added that and PHP no longer dies. But I still can't get the Prefilter to change the output even if I totally replace the source using: filtered content"; } } $tpl = new PHPTAL('mytemplate.html'); $tpl->setPreFilter(new MyPreFilter()); echo $tpl->execute(); ?> It would really help if I can see a sample that's known to work. Ah, that's a bug I've fixed last month :) You need to make PHPTAL re-parse the template, otherwise changes in prefilter won't be noticed (touch the file or clear cache in /tmp). -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal