1

I'm using an old version of symfony 1.0.11

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

The problem with this code is that parameter and value do not get passed, so If i click on home i get /module/action but the parameters are not being passed. Any suggestions?

Thanks.

4

2 回答 2

1

There is also a way automatically set the breadcrumbs this is in the breadcrumbs actions:

// 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;

then in the component itself, you can foreach through the paths and if empty just continue. And always give the GET variables with the link if the browser has some.

<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; ?>

This way you never have to set your breadcrumbs if you have a correct url structure.

于 2012-08-14T08:31:20.290 回答
0

the way i fixed it is

include_component('page','breadcrumbs',array('past_pages'=>array(
  '/module/action?parameter=value'=>'Home ')));
于 2012-08-02T13:17:19.317 回答