eZURLWilcard做URL跳转

前段时间做的一个项目,先把代码放这:

I used eZURLWilcard to do this.

eZURLWilcard would create and store two php files in the /var/ezwebin_site/cache/wildcard/

I edited them, to redirect to the URL we wanted, and changed the permissions(755) to protect them.

The content of the two files is:

wildcard_04edd92347361aea4ba9f8857b265e72_0.php

function eZURLWilcardCachedTranslate( $wildcardNum, &$uri, &$wildcardInfo, $matches )
{
switch ( $wildcardNum )
{
case 0:
{
$nodeID = eZURLAliasML::fetchNodeIDByPath( “Users/HVAF-Members/” . $matches[1] ); //e.g fetchNodeIDByPath(’/About/Company’)
//$contentNode = eZContentObjectTreeNode::fetch( $nodeID );
$params=array(’Limit’=>’1′,
‘ClassFilterType’=>’include’,
‘ClassFilterArray’=>array(’gallery_basic’, ‘gallery_standard’, ‘gallery_extended’));
$nodes = eZContentObjectTreeNode::subTreeByNodeID($params,$nodeID);
$uri=$nodes[0]->attribute(’url’);
//$uri = “Users/HVAF-Members/” . $matches[1] . “/” . $matches[2] . “”;
$wildcardInfo = array( ‘id’ => ‘6′,
’source_url’ => ‘*/gallery’,
‘destination_url’ => ‘Users/HVAF-Members/{1}/{2}’,
‘type’ => ‘2′ );
} break;
};
}

wildcard_04edd92347361aea4ba9f8857b265e72_index.php

function eZURLWilcardCachedReqexpArray()
{
$wildcards = array(
“#^(.*)/gallery#”
);
return $wildcards;
}

留下回复