1

古いバージョンの symfony 1.0.11 を使用しています

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

このコードの問題は、パラメーターと値が渡されないことです。そのため、ホームをクリックすると /module/action が取得されますが、パラメーターが渡されません。助言がありますか?

ありがとう。

4

2 に答える 2

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

このように、正しいURL構造があれば、ブレッドクラムを設定する必要はありません。

于 2012-08-14T08:31:20.290 に答える
0

私がそれを修正した方法は

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