本文整理汇总了PHP中Posts::ascend方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::ascend方法的具体用法?PHP Posts::ascend怎么用?PHP Posts::ascend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Posts
的用法示例。
在下文中一共展示了Posts::ascend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: js
private function js($theme)
{
// If there's a single post, ascend or descend appropriately
if ($theme->posts instanceof Post) {
$next = Posts::ascend($theme->posts)->permalink;
$previous = Posts::descend($theme->posts)->permalink;
} else {
$page = $theme->page;
$items_per_page = isset($theme->posts->get_param_cache['limit']) ? $theme->posts->get_param_cache['limit'] : Options::get('pagination');
$total = Utils::archive_pages($theme->posts->count_all(), $items_per_page);
if ($page + 1 > $total) {
$next = '';
} else {
$next = URL::get(null, array('page' => $page + 1));
}
if ($page - 1 < 1) {
$previous = '';
} else {
$previous = URL::get(null, array('page' => $page - 1));
}
}
$delay = Options::get('key_nav_delay');
$selector = Options::get('key_nav_selector');
return <<<KEYNAV
\$(document).ready(function() {
\tcurrent = 0;
\t\$.hotkeys.add('j', {propagate:true, disableInInput: true}, function(){
\t\tif (current == \$('{$selector}').length-1) {
\t\t\tif ('{$next}' == '') {
\t\t\t\t// TODO Show the no more posts message
\t\t\t} else {
\t\t\t\t// go to next page
\t\t\t\twindow.location = '{$next}';
\t\t\t}
\t\t} else {
\t\t\ttarget = \$('{$selector}').eq(current+1).offset().top
\t\t\t\$('html,body').animate({scrollTop: target}, {$delay});
\t\t\tcurrent++;
\t\t}
\t});
\t\$.hotkeys.add('k', {propagate:true, disableInInput: true}, function(){
\t\tif (current == 0) {
\t\t\tif ('{$previous}' == '') {
\t\t\t\t// Show the no more posts message
\t\t\t} else {
\t\t\t\t// go to previous page
\t\t\t\twindow.location = '{$previous}';
\t\t\t}
\t\t} else {
\t\t\ttarget = \$('{$selector}').eq(current-1).offset().top
\t\t\t\$('html,body').animate({scrollTop: target}, {$delay});
\t\t\tcurrent--;
\t\t}
\t});
});
KEYNAV;
}
示例2: ascend
/**
* Returns the ascending post, relative to this post, according to params
* @params The params by which to work out what is the ascending post
* @return Post The ascending post
*/
public function ascend( $params = null )
{
return Posts::ascend( $this, $params );
}