| 
	
 | 
 Posted by David Haynes on 06/20/06 20:48 
msch-prv@bluewin.ch wrote: 
> I am about to embark on creating a mid-size web project that heavily 
> relies on db interactions. 
>  
> Since most pages will contain recurring form elements (input text 
> boxes, dropdown boxes, radio buttons, submit forms, tables, etc.), I am 
> thinking of using blocks to insert components to each page. All 
> standard elements would be instances of form element classes. Calling 
> up these objects would generate customized html code. 
>  
> Ex: a cbo box could be instantiated in a script via: 
> <p>Select Customer:</p><?php creatElement($cboName, $cboCSS, $cboVal, 
> $cboOpt, ..); ?> 
>  
> Would such an approach be more efficient that the traditional 
> line-by-line approach wrt. debugging, maintenance, etc. ? (I really 
> dread mixing php and html.). While I like Smarty's templating approach, 
> it seems Smarty still requires linear coding to do code translation. 
>  
> I visualize html pages in terms of grids where cells could be filled up 
> by html block components. Is this approach somewhat too fancy? 
>  
> Thanks for any insights, 
>  
> Mark 
>  
This approach is very similar to the Java tag libraries approach. You  
may want to check out their design to piggy-back on their experience. I  
would suggest that you especially look at the html taglib set. 
 
The lack of polymorphism will be a bit of a hindrance but this can be  
worked around by using arrays instead of individual function variables.  
For example: 
<p>Select Customer: <?php htmlSelect($attributes, $options);?> 
 
Where $attributes is an associative array of tag=value for the  
attributes of <select> and $options is an associative array for the  
<option> attributes. 
 
-david-
 
[Back to original message] 
 |