paginationControl パーシャルを使用し、パラメーターを 4 番目のパラメーターに渡して、「フィルター処理された」結果をページ分割できるようにしています。それは正常に機能していますが、異なるパラメーターを使用する場合でも、ページネーションのすべてのインスタンスに対して同じパーシャルを使用できるようにしたいと考えています。
たとえば、「プロパティ」は no でフィルタリングされます。寝室
ビュースクリプトのページネーションコントロールのインスタンスに4番目のパラメータを与える...
array('beds' => '$beds')
部分的に使用されます...
$this->beds
一方、「クライアント」は場所によってフィルタリングされます
ビュースクリプトのページネーションコントロールのインスタンスに4番目のパラメータを与える...
array('location' => '$location')
部分的に使用されます...
$this->location
これを達成する最善の方法は?キーと値の配列として 4 番目のパラメーターにアクセスし、配列をループして、配列にアクセスする方法を理解できれば、paginationControl 部分内の URL ビュー ヘルパーの引数を作成できます。しかし、おそらくそれはとにかく取るべきアプローチではありません..
ありがとう。
編集:
これは、コメントで要求されたページネーション コントロールを出力するために使用しているパーシャルです。
<div class="pagination">
<div class="pages">
<!-- First page link -->
<?php if (isset($this->previous)): ?>
<a href="<?= $this->url() . "?" . http_build_query(array('group_id' => $this->group_id, 'page' => $this->first)); ?>">Start</a>
<?php else: ?>
<span class="disabled">Start</span>
<?php endif; ?>
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="<?= $this->url() . "?" . http_build_query(array('group_id' => $this->group_id, 'page' => $this->previous)); ?>">Previous</a>
<?php else: ?>
<span class="disabled">Previous</span>
<?php endif; ?>
<!-- Numbered page links -->
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<a href="<?= $this->url() . "?" . http_build_query(array('group_id' => $this->group_id, 'page' => $page)); ?>"><?= $page; ?></a>
<?php else: ?>
<span class="current"><?= $page; ?></span>
<?php endif; ?>
<?php endforeach; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
<a href="<?= $this->url() . "?" . http_build_query(array('group_id' => $this->group_id, 'page' => $this->next)); ?>">Next</a>
<?php else: ?>
<span class="disabled">Next</span>
<?php endif; ?>
<!-- Last page link -->
<?php if (isset($this->next)): ?>
<a href="<?= $this->url() . "?" . http_build_query(array('group_id' => $this->group_id, 'page' => $this->last)); ?>">End</a>
<?php else: ?>
<span class="disabled">End</span>
<?php endif; ?>
</div>
</div>
アップデート:
ページネーション コントロール パーシャルのインスタンス化で 4 番目のパラメーターを介して渡されたパラメーターにアクセスするという基本的な質問に答えるため、私は RockyFords ソリューションを受け入れました。ただし、別の読者が結果のパラメーターでクエリ文字列を生成する必要がある場合に備えて、完全なフィナ パーシャルをここに含めます。
<div class="pagination">
<div class="pages">
<?php
$params = Zend_Controller_Front::getInstance()->getRequest()->getParams();
unset($params['controller']);
unset($params['action']);
?>
<?= $this->first ?>
<!-- First page link -->
<?php if (isset($this->previous)): ?>
<a href="<?= $this->url() . "?" . http_build_query(array_merge($params , array('page' => $this->first))); ?>">Start</a>
<?php else: ?>
<span class="disabled">Start</span>
<?php endif; ?>
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="<?= $this->url() . "?" . http_build_query(array_merge($params , array('page' => $this->previous))); ?>">Previous</a>
<?php else: ?>
<span class="disabled">Previous</span>
<?php endif; ?>
<!-- Numbered page links -->
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<a href="<?= $this->url() . "?" . http_build_query(array_merge($params , array('page' => $page))); ?>"><?= $page; ?></a>
<?php else: ?>
<span class="current"><?= $page; ?></span>
<?php endif; ?>
<?php endforeach; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
<a href="<?= $this->url() . "?" . http_build_query(array_merge($params , array('page' => $this->next))); ?>">Next</a>
<?php else: ?>
<span class="disabled">Next</span>
<?php endif; ?>
<!-- Last page link -->
<?php if (isset($this->next)): ?>
<a href="<?= $this->url() . "?" . http_build_query(array_merge($params , array('page' => $this->last))); ?>">End</a>
<?php else: ?>
<span class="disabled">End</span>
<?php endif; ?>