PHP Classes

Template Phrasing

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  PHP Forms Class with HTML Generator and JavaScript Validation package blog  >  How to Show Google Ma...  >  All threads  >  Template Phrasing  >  (Un) Subscribe thread alerts  
Subject:Template Phrasing
Summary:There can be a Template Based Version of this Excellent Class
Messages:3
Author:Shoeb
Date:2006-07-30 20:40:27
Update:2006-07-31 05:47:34
 

  1. Template Phrasing   Reply   Report abuse  
Picture of Shoeb Shoeb - 2006-07-30 20:40:27
Hi Manuel,

This class is damm good although i am in the initial stages of understanding it but the biggest drawback of this class is that it cannot use template phrasing and i was stick to route your way of using my template files with PHP code. Anyways Smarty also does the same thing but i am not using smarty rather I have my own template phrasing engine. So i had to modify you code inorder to make it this way...

$cv['INPUT_FORM_TITLE']= $form->AddInputPart("userfile");

and now this will give me only the JS validation codes and other things rather than giving me the entire form... So i have various form elemebts into an array and then i renter my template for the array i have. Now my rendered template file has all the element i fetched using your class... I modified your function output($argument) to not to supply me the form tag each time i call AddInputPart function (as i am getting the element details by calling the Output function in AddInputPart ;) ) and so i have written another function in the class to make the form i.e. add the form tags as per the conditions i had set in my calling php page..

well a lot of thinking and brainstroming and finally I guess I am there to give you the modified version of this class. Please advice that if i offer you the modified version you wont be offended and i want you to upload the new version for the betterment of the community.

Regards,
Accilies

  2. Re: Template Phrasing   Reply   Report abuse  
Picture of Shoeb Shoeb - 2006-07-30 20:42:06 - In reply to message 1 from Shoeb
sorry for the spelling its Parsing :)

  3. Re: Template Phrasing   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-07-31 05:47:34 - In reply to message 1 from Shoeb
I am always open to improvement contributions as long as they benefit many users and do not require adding too much code to the core class. Alternatively, the class can also be extended without affecting the code class by the means of plug-ins.

As for your problem, the AddInputPart class does not generate any form output. It just tells the class where you want to make appear a given input.

What happens is that the class can only generate the whole form output when it is aware of all the fields that will appear in the final form composition.

To compose the form output, you can interleave calls to AddInputPart, AddLabelPart and AddDataPart. Alternatively you can print HTML tags mixed with AddInputPart and AddLabelPart calls, within a section defined by calls to StartLayoutCapture and EndLayoutCapture. This is what most examples use.

The Smarty plug-in is a pre-filter. It replaces {input} and {label} marks by tags that make the template engine call AddInputPart, AddLabelPart and AddDataPart function.

Maybe you can make your template engine work similarly.