From: Alain Williams on
Try again - this time with a proper Subject and with the
renderer attached.

On Fri, Nov 13, 2009 at 04:09:33PM +0000, Alain Williams wrote:

> I am writing an renderer for Smarty - I have taken the array renderer and am modifying/butchering/... it.
> I am aiming to product an array (which is what Smarty wants) that is compatible with current
> Smarty templates -- ie you are going to need to change the PHP, but hopefully will
> not have to change the templates.

Please find attached some new files that implement the above: a Smarty renderer for QuickForm2

* Renderer.php
Modified to know about the smarty renderer.
Accept a new option 'old_compat' - this causes the smarty renderer to do somethings
that might not be wanted if you were starting from new. The point is that it allows
existing smarty templates to be used without change.

* Smarty.php
This implements a renderer. It works - at least in the way that I use QuickForm.
There are some things not implemented, I prob did not understand how to do it
with QuickForm.
There are some comments saying what the returned array contains.

This was developed under PHP 5.3 on Linux.

To see how this plugs together see a tutorial set that I have at:

http://www.phcomp.co.uk/TechTutorial/QfSmarty/index.php

(This runs the QuickForm and NOT the QuickForm2 version, but the output
is the same).

All feedback gratefully accepted.

This is cross posted to both the PEAR-GENERAL and the SMARTY-DEV
mail lists since it is relevant to both.

Have fun!

--
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256 http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
Past chairman of UKUUG: http://www.ukuug.org/
#include <std_disclaimer.h>
From: Alexey Borzov on
Hi Alain,

Alain Williams wrote:
> Try again - this time with a proper Subject and with the
> renderer attached.

You are using the smarty-dev list that is defunct for quite a bit of time:
http://news.php.net/php.smarty.dev/3071

> On Fri, Nov 13, 2009 at 04:09:33PM +0000, Alain Williams wrote:
>
>> I am writing an renderer for Smarty - I have taken the array renderer and am modifying/butchering/... it.
>> I am aiming to product an array (which is what Smarty wants) that is compatible with current
>> Smarty templates -- ie you are going to need to change the PHP, but hopefully will
>> not have to change the templates.
>
> Please find attached some new files that implement the above: a Smarty renderer for QuickForm2
>
> * Renderer.php
> Modified to know about the smarty renderer.
> Accept a new option 'old_compat' - this causes the smarty renderer to do somethings
> that might not be wanted if you were starting from new. The point is that it allows
> existing smarty templates to be used without change.

You could add this option in your Renderer's constructor, no need to patch the
base class.

> * Smarty.php
> This implements a renderer. It works - at least in the way that I use QuickForm.
> There are some things not implemented, I prob did not understand how to do it
> with QuickForm.
> There are some comments saying what the returned array contains.

I had a brief look at your implementation:
1) Why aren't you extending the Array renderer? 2/3 of your class is copy-pasted
from there.
2) Why do you have some hardcoded HTML inside the renderer?

I can't really comment on its behaviour, since I'm not using Smarty and don't
have code to run, so you'll have to wait for someone who does. I'd suggest
trying the Smarty mailing lists once again, active ones this time. ;]


> This was developed under PHP 5.3 on Linux.
>
> To see how this plugs together see a tutorial set that I have at:
>
> http://www.phcomp.co.uk/TechTutorial/QfSmarty/index.php
>
> (This runs the QuickForm and NOT the QuickForm2 version, but the output
> is the same).
>
> All feedback gratefully accepted.
>
> This is cross posted to both the PEAR-GENERAL and the SMARTY-DEV
> mail lists since it is relevant to both.
>
> Have fun!

From: Alain Williams on
On Thu, Nov 19, 2009 at 04:51:36PM +0300, Alexey Borzov wrote:
> Hi Alain,
>
> Alain Williams wrote:
> >Try again - this time with a proper Subject and with the
> >renderer attached.

A new version is attached.

> >* Renderer.php

> You could add this option in your Renderer's constructor, no need to patch
> the base class.

Hmmm: your class inheritance is complicated - I can't see how to do that.
Could I ask you to do that and post a version back.


> I had a brief look at your implementation:
> 1) Why aren't you extending the Array renderer? 2/3 of your class is
> copy-pasted from there.

True - I did not realise how small the changes would be.
The new version works by taking 2 options to the array renderer:
* smarty -- this has most effect
* old_compat -- needed for existing templates, prob not neede for new templates

> 2) Why do you have some hardcoded HTML inside the renderer?

There is now just a small amount in gneration of requirednote.


To see how this plugs together see a tutorial set that I have at:

http://www.phcomp.co.uk/TechTutorial/QfSmarty/index.php

(This runs the QuickForm and NOT the QuickForm2 version, but the output
is the same).

All feedback gratefully accepted.

--
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256 http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
Past chairman of UKUUG: http://www.ukuug.org/
#include <std_disclaimer.h>