[development] Node Rendering Debate

David Metzler metzlerd at metzlerd.com
Fri Jun 22 15:22:54 UTC 2007


Wish I could be at drupalCon for that one.

One useful thing would be to have that node structuring conversation  
outside of the question about objects or not.  In php 5, object  
properties can be iterated in the same way that arrays can, both in  
terms of extract and foreach as is illustrated by the following php5  
code:

<?php
$object = simplexml_load_string('<node><var1>value1</ 
var1><var2>value2</var2></node>');
extract((array)$object);
?>
<?php print "Variable1:".$var1;
?>

I wrote a RAILS partials knock-off in an insanely simple php library,  
which I'll include a modified version to illustrate my point.  It  
seems that a well structured node (object or array) with some good  
rendering functions kind of like the way views theming works, would  
be a very powerful way to implement this.

Can't wait till PHP5 and Drupal 7 ;)

<?php

/**
* Render a partial template from an array.
* @param $info an two dimensional array to iterate through for partial
* @param $template the template to execute for the partial.
*/
function render_partial($item,$partial,$name='',$extract=true) {
   if ((is_array($item) || is_object($item)) && $extract==true)  {
     extract((array)$item);
   }
   include("partials/".$partial.".php");
}
/**
* Render a partial template from an array.
* @param $info an array to itterate through as the partical
* @param $template the template to execute for the partial.
*/
function render_collection_of_partials($collection,$partial,$name='', 
$extract=true) {
   foreach ($collection as $item)  {
     render_partial($item,$partial,$name,$extract);
   }
}


On Jun 21, 2007, at 7:10 PM, Derek Wright wrote:

>
> On Jun 21, 2007, at 6:42 PM, Jeff Eaton wrote:
>
>> It is a tremendously powerful system. We shouldn't jump into using  
>> it unawares, but we would also be missing a huge opportunity to  
>> pass up this system of storing meta-data rich structures and  
>> renderable content.
>
> Jeff and I just discussed on IRC...
>
> Whereas, there's no solid agreement yet on if/how this should  
> happen, and
>
> Whereas, even a partial implementation of this to fix $node  
> namespace bugs would require a massive patch that breaks all of  
> contrib and every patch in the core queue right now, and
>
> Whereas, neither of us has time for the massive effort it would  
> take to write and maintain such a patch, and,
>
> Whereas, neither of us want to be responsible for the D6 equivalent  
> of the "4.7 FAPI debacle" at this late hour in the development  
> cycle, and
>
> Whereas, there are lots of other great patches that could use our  
> collective attention that *do* still have a chance of landing for  
> D6...
>
>
> Therefore, be it resolved, that we're hereby "throwing in the  
> towel" (giving up) on trying to get this into D6.
>
> Jeff already added a section on "node structuring" to the DrupalCon  
> agenda in September.  We both agree that giving this proper thought  
> and doing it completely and early in D7 is the best course of action.
>
> Active >> Postponed
>
> ;)
>
> Thanks,
> -Derek
>
>



More information about the development mailing list