Re: HTTP_Template_Flexy Questions
| From: | Alan Knowles | Date: | Tue, 10 Aug 2004 00:30:46 +0000 |
| Subject: | Re: HTTP_Template_Flexy Questions | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14032@lists.php.net to get a copy of this message | ||
you can use
$x['form'] = new HTML_Template_Flexy_Element;
$hidden = new HTML_Template_Flexy_Element('input',array('type'=>'hidden'));
foreach($hiddenValues as $k=>$v) {
$h = clone($hidden);
$h->attributes['name'] = $k;
$h->attributes['value'] = $v;
$x['form']->children[] = $h;
}
Should do that..
Regards
Alan
Jamie Wall wrote:
I notice in the comments for toHtmlnoClose:* Output Open Tag and any children and not Child tag (designed for use with <form + hidden elements>Would you explain the hidden elements part? That might solve my problem, as I am trying to rewrite the form element with hidden elements using the notion of element->suffix. Maybe, based on this comment, there is already a way. Thanks. Jamie Wall http://www.webpeak.com 1(727)527-3646 Alan Knowles wrote:Jamie Wall wrote:First: I am really finding Flexy useful! Second: I have 2 questions concerning the use of Flexy: 1. Is there a way to use prefix/suffix with form tags? To make it work for me, I am modifying HTTP_Template_Flexy_Element method toHtmlNoClose() like: return "{$prefix}<{$ret->tag}".$ret->attributesToHTML() . '>' . $ret->childrenToHTML() . $suffix;It would involve adding an extra call to the page: $this->elements['formName']->closeToHtml(); put it as a feature request on the package bug page.. - with code if you have time..2. Is their a way to compile/output a string which contains the template instead of using a file on disk? I see: function compile(&$flexy,$string=false) in HTML_Template_Flexy_Compiler_Standard, but I also want mergeElement functionality which is in outputObject/bufferedOutputObject which seems to rely on a template on disk. I have it mostly working, but again I have to modify/subclass which doesn't seem right.There is.. :) - although it's not normally recommended as the compiling stage is not very fast (eg. expect 100% CPU utilization on anything over 100 lines).. class StringCompiler extends HTML_Template_Flexy {var $compiledString; function StringCompiler($opts) { $opts['compileToString'] = true; parent::HTML_Template_Flexy($opts); } function compile($string) {$compiler = HTML_Template_Flexy_Compiler::factory($this->options);$this->compiledString = $compiler->compile($x,$string); } function outputObject($t,$elements) { eval($this->compiledString); }} you may want to look at the Flexy Source a bit more to add features, but the basic stuff should work by doing this.. Regards AlanThank you in advance. Jamie Wall http://www.webpeak.com 1(727)527-3646