나는 젠드 프레임 워크 애플리케이션을 개발 중이며 http://tfountain.co.uk/blog/2010/9/9/vanity-urls-zend-framework/에있는 가이드를 사용하여 나의 허영 라우팅 작업을 수행하고 있지만 페이지 매김이 작동하지 않으며 허영성 URL 가이드가 ' 그것을 만질 수있었습니다.젠드 프레임 워크 베니 티 URL 페지 네이션이 작동하지 않음
내 화장대 경로는 마지막 2 개의 매개 변수가 선택적 인 /:username/:filter/:pag
'으로 설정됩니다. 페이지가 제대로 표시되고 '/ jaimerump/badges/2'는 내 배지의 두 번째 페이지로 이동하지만 다음 페이지의 URL이 무엇인지 알아낼 수 없으므로 페이지 매기기가 작동하지 않습니다. 여기, 모든 젠드 매김 튜토리얼에서 코드를 표준 paginationControl.phtml 파일을 사용하고 있습니다 :
<?php if ($this->pageCount): ?>
<div class="paginationControl" id="paginationControl">
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="<?php echo $this->url(array('page' => $this->previous)); ?>" id="previous">
< Previous
</a> |
<?php else: ?>
<span class="disabled">< Previous</span> |
<?php endif; ?>
<!-- Infinite Scroll doesn't use numbered page links -->
<!-- Next page link -->
<?php if (isset($this->next)): ?>
<a id="next" href="<?php echo $this->url(array('page' => $this->next)); ?>" >
Next >
</a>
<?php else: ?>
<span class="disabled">Next ></span>
<?php endif; ?>
</div>
<?php endif; ?>
을 대신 '/ jaimerump/배지/3', $this->url()
수익을 '/'반환하는. 나는 이것이 나의 주문의 길 클래스와 관계가있다라고 확신한다. Tim Fountain의 튜토리얼에서 match 함수를 변경했고 클래스의 이름을 VanityRouteUser로 변경하고 모델 폴더에 넣었습니다. 그러나 그 외 모든 것은 동일합니다. 일치 기능 :
public function match($path, $partial = false)
{
/* User profile routes are of form /:username/:filter/:page
Where filter can be haves, wants, badges, etc.
*/
if ($path instanceof Zend_Controller_Request_Http) {
$path = $path->getPathInfo();
}
$path = trim($path, $this->_urlDelimiter);
$pathBits = explode($this->_urlDelimiter, $path);
if (count($pathBits) < 1) {
return false;
}
// check database for this user
$result = DB::call()->fetchRow('SELECT user_id
FROM users
WHERE username = ?', $pathBits[0]);
if ($result) {
// user found
$values = $this->_defaults;
$values['username'] = $pathBits[0];
$values['page'] = (empty($pathBits[2]))?1:$pathBits[2]; //if they didn't provide a page
// figure out which action based on second segment
$filter = $pathBits[1];
if(empty($filter) || $filter == 'default'
|| $filter == 'haves' || $filter == 'wants'){
//Looking for user's haves, wants, or both
$values['action'] = 'index';
$values['filter'] = (empty($filter))?'default':$filter; //To catch the blank
}
else if($filter == 'badges'){
//Looking for user's badges
$values['action'] = 'badges';
}
else if($filter == 'shelves'){
//Looking for user's shelves
$values['action'] = 'shelves';
}
else{
//Must be a shelf id
$values['action'] = 'index';
$values['filter'] = $filter;
}
return $values;
}
return false;
}
무엇이 $this->url()
입니까? Zend Paginator에서 URL 함수를 찾을 수 없었습니다. 그리고 그것은 다음 페이지의 URL을 얻기 위해 라우트 클래스의 일부 함수를 호출하고 있다고 가정합니다. 어떤 기능을 호출하고 있으며 과부하를해야합니까?
다행입니다. FYI'$ this-> url()'은 표준 ZF URL 도우미를 호출하고, 관련 경로에 대한 assemble을 호출합니다. 이 함수는 원하는 것을 반환 할 수 있으므로 필터 및 페이지 매개 변수가 제공된 경우이를 포함하도록 솔루션을 쉽게 수정할 수 있습니다. –
@TimFountain이 경우,'$ this'는 무엇을 의미합니까? 호출되는 다른 모든 기능 및 속성에서 페이지 매기기가되어야하는 것처럼 보입니다. paginator가 가지고 있지 않은 함수를 호출하려고 할 때 모든 도우미를 자동으로 검사합니까? – jaimerump
'$ this'는'Zend_View' 인스턴스가 될 것입니다. 페이징 기는 부분적으로 렌더링하려고 시도 할 때 뷰에 다른 모든 변수를 할당합니다 (아마도 부분 도우미를 통해). –