Wednesday 09 July 2008 2:24:51 am
here, an example to explicate how to do a dynamic block. We will make a block 8 random Recipes of the parent folder recipes node 999. firstly, in the block.ini
#section_name + 'Layout_zone' + zone_number
#Solution for avoid all block in adding list of zone layout
#see http://ez.no/developer/forum/extensions/ez_flow/solution_for_avoid_all_block_in_adding_list_of_zone_layout
[CookingLayout_zone2]
AllowedTypes[]
AllowedTypes[]=RecipesRandom
[RecipesRandom]
Name=RecipesRandom
NumberOfValidItems=8
NumberOfArchivedItems=0
ManualAddingOfItems=disabled
FetchClass=LARandomObjects
FetchFixedParameters[]
FetchFixedParameters[Class]=recipe
FetchParameters[]
FetchParameters[Source]=nodeID
FetchParameters[Depth]=2
FetchParameters[Limit]=8
FetchParametersSelectionType[Source]=single
FetchParametersIsRequired[]
FetchParametersIsRequired[Source]=true
FetchParametersIsRequired[Depth]=true
FetchParametersIsRequired[Limit]=true
ViewList[]=8_recipes_random
ViewName[8_recipes_random]=8 Recipes Random
#Time for change the block after the crontab ezflow passed.
TTL=1800
and then, we should create the class FetchClass. so create larandomobjects.php in ezflow/classes/fetches
<?php
/**
* LARandomObjects
* @author LIU Bin <[email protected]>
*/
include_once( 'extension/ezflow/classes/ezflowfetchinterface.php' );
class LARandomObjects extends eZFlowFetchInterface
{
function fetch( $parameters, $publishedAfter, $publishedBeforeOrAt )
{
if ( isset( $parameters['Source'] ) )
{
$nodeID = $parameters['Source'];
$node = eZContentObjectTreeNode::fetch( $nodeID, false, false ); // not as an object
}
else
{
$nodeID = 0;
}
$subTreeParameters = array();
$subTreeParameters['AsObject'] = false;
$subTreeParameters['Limit'] = isset( $parameters['Limit'] ) ? $parameters['Limit']:false;
$subTreeParameters['Depth'] = isset( $parameters['Depth'] ) ? $parameters['Depth']:false;
if ( isset( $parameters['Class'] ) )
{
$subTreeParameters['ClassFilterType'] = 'include';
$subTreeParameters['ClassFilterArray'] = explode( ';', $parameters['Class'] );
}
$result = hfpFetchRandom::subTreeRandomByNodeID( $subTreeParameters, $nodeID );
$fetchResult = array();
foreach( $result as $item )
{
$fetchResult[] = array( 'object_id' => $item['contentobject_id'],
'node_id' => $item['node_id'],
'ts_publication' => $item['published'] );
}
return $fetchResult;
}
}
?>
the class Fetch random see http://projects.ez.no/la_fetch_random And in the ezflow bo, add source folder 999, config depth 2 and limit 8, and validate. it works.
=== Lagardère Active ===
Fetch random
http://projects.ez.no/la_fetch_random
LA Static Cache
http://projects.ez.no/lastaticcache
LA Bookmarks (jquery)
http://projects.ez.no/labookmark
LA Calendar (jquery)
http://projects.ez.no/lacalendar
My site ez
http://lingping.info
|