2012-08-01 212 views
1

我使用的是旧版本的symfony 1.0.11面包屑Symfony的

slot('breadcrumbs'); 
    include_component('page','breadcrumbs',array('past_pages'=>array(
     '/module/action/parameter/value'=>'Home '))); 
    end_slot(); 

这段代码的问题是,参数和价值没有得到通过,所以如果我回家,我得到/模块点击/行动但参数未被传递。有什么建议么?

谢谢。

回答

0

我固定它是

include_component('page','breadcrumbs',array('past_pages'=>array(
    '/module/action?parameter=value'=>'Home '))); 
1

还有自动设置面包屑,这是面包屑行动的方式方法:

// Get the full path without get parameters 
$fullPath = $request->getPathInfo(); 

// get the get parameters 
$urlParams = $request->getGetParameters(); 

// set get parameters as string for url 
$this->extend = ""; 
foreach ($urlParams as $key => $urlParam) { 
    if (empty($this->extend)) { 
     $this->extend = "?"; 
    } 
    this->extend .= $key."=".$urlParam; 
} 

// Get the URL path and Explode by/
$paths = explode('/', $fullPath);; 
$this->paths = $paths; 

然后在组件本身,你可以的foreach通过路径和空如果继续。如果浏览器有一些,那么总是给链接GET变量。

<a href="<?php echo url_for("home").$extend; ?>">Home</a> 
<?php foreach($paths as $path): 
    if(empty($path)) 
     continue; 

    if(empty($fullPath)) 
     $fullPath = ""; 

    $fullPath .= "/".$path.$extend; 
    $path = str_replace("-", " ", $path); 
?> 
<?php if(key($paths->getRawValue()) != (count($paths)-1)): ?> 
    <a href="<?php echo $fullPath; ?>"><?php echo ucwords($path); ?></a> 
<?php else: ?> 
    <span><?php echo ucwords($path); ?></span> 
<?php endif; ?> 

这样,如果您有正确的网址结构,您无需设置您的面包屑。