diff --git a/_build/properties/properties.getpage.php b/_build/properties/properties.getpage.php index 2695283..c2a84e5 100644 --- a/_build/properties/properties.getpage.php +++ b/_build/properties/properties.getpage.php @@ -151,6 +151,20 @@ 'options' => '', 'value' => '', ) + ,array( + 'name' => 'placeholderNav', + 'desc' => 'Wether or not to display placeholder nav\'s when there is no way to go', + 'type' => 'combo-boolean', + 'options' => '', + 'value' => 'true', + ) + ,array( + 'name' => 'placeholderClasses', + 'desc' => 'Classes to apply on placeholder nav\'s', + 'type' => 'textfield', + 'options' => '', + 'value' => 'disabled', + ) ); -return $properties; \ No newline at end of file +return $properties; diff --git a/core/components/getpage/include.getpage.php b/core/components/getpage/include.getpage.php index 7280a48..68f1377 100644 --- a/core/components/getpage/include.getpage.php +++ b/core/components/getpage/include.getpage.php @@ -8,13 +8,14 @@ function getpage_buildControls(& $modx, $properties) { $page = !empty($properties['page']) ? $properties['page'] : 1; $pageCount = !empty($properties['pageCount']) ? $properties['pageCount'] : 1; $pageLimit = $properties['pageLimit']; + $placeholderNav = $properties['placeholderNav']; extract($properties, EXTR_SKIP); if ($pageCount > 1 && !empty($pageNavTpl)) { for ($i = 1; $i <= $pageCount; $i++) { - if ($i == 1 && $i != $page && !empty($pageFirstTpl)) { - $nav['first'] = getpage_makeUrl($modx, $properties, $i, $pageFirstTpl); - if (!empty($pagePrevTpl) && ($page - 1) >= 1) { - $nav['prev'] = getpage_makeUrl($modx, $properties, $page - 1, $pagePrevTpl); + if ($i == 1 && ($placeholderNav || $i != $page) && !empty($pageFirstTpl)) { + $nav['first'] = getpage_makeUrl($modx, $properties, ($i == $page)? -1:$i, $pageFirstTpl); + if (!empty($pagePrevTpl) && ($placeholderNav || $i != $page)) { + $nav['prev'] = getpage_makeUrl($modx, $properties, ($i == $page)? -1:$page - 1, $pagePrevTpl); } } if (empty($pageLimit) || ($i >= $page - $pageLimit && $i <= $page + $pageLimit)) { @@ -25,11 +26,11 @@ function getpage_buildControls(& $modx, $properties) { $nav['pages'][$i] = getpage_makeUrl($modx, $properties, $i, $pageNavTpl); } } - if ($i == $pageCount && $i != $page && !empty($pageLastTpl)) { - if (!empty($pageNextTpl) && ($page + 1) <= $pageCount) { - $nav['next'] = getpage_makeUrl($modx, $properties, $page + 1, $pageNextTpl); + if ($i == $pageCount && ($placeholderNav || $i != $page) && !empty($pageLastTpl)) { + if (!empty($pageNextTpl) && ($placeholderNav || ($page + 1) <= $pageCount)) { + $nav['next'] = getpage_makeUrl($modx, $properties, ($page == $pageCount)? -1:$page +1, $pageNextTpl); } - $nav['last'] = getpage_makeUrl($modx, $properties, $i, $pageLastTpl); + $nav['last'] = getpage_makeUrl($modx, $properties, ($page == $pageCount)? -1:$i, $pageLastTpl); } } $nav['pages'] = implode("\n", $nav['pages']); @@ -45,8 +46,11 @@ function getpage_makeUrl(& $modx, $properties, $pageNo, $tpl) { $qs[$properties['pageVarKey']] = $pageNo; } $scheme = !empty($properties['pageNavScheme']) ? $properties['pageNavScheme'] : $modx->getOption('link_tag_scheme', $properties, -1); - $properties['href'] = $modx->makeUrl($modx->resource->get('id'), '', $qs, $scheme); + $properties['href'] = ($pageNo!=-1)?$modx->makeUrl($modx->resource->get('id'), '', $qs, $scheme):'#'; $properties['pageNo'] = $pageNo; + + if($pageNo == -1) //nav is placeholder, probebly a better way than -1 to pas this though + $properties['classes'] = ' class="'.$properties['placeholderClasses'].'"'; $nav= $modx->newObject('modChunk')->process($properties, $tpl); return $nav; } diff --git a/core/components/getpage/snippet.getpage.php b/core/components/getpage/snippet.getpage.php index 6e7c7cc..3686cee 100644 --- a/core/components/getpage/snippet.getpage.php +++ b/core/components/getpage/snippet.getpage.php @@ -31,6 +31,7 @@ $properties['pageNextTpl'] = !isset($pageNextTpl) ? "
  • >>
  • " : $pageNextTpl; $properties['toPlaceholder'] = !empty($toPlaceholder) ? $toPlaceholder : ''; $properties['cache'] = isset($cache) ? (boolean) $cache : (boolean) $modx->getOption('cache_resource', null, false); +$properties['placeholderClasses'] = !empty($placeholderClasses) ? $placeholderClasses : 'disabled'; if (empty($cache_key)) $properties[xPDO::OPT_CACHE_KEY] = $modx->getOption('cache_resource_key', null, 'resource'); if (empty($cache_handler)) $properties[xPDO::OPT_CACHE_HANDLER] = $modx->getOption('cache_resource_handler', null, 'xPDOFileCache'); if (empty($cache_expires)) $properties[xPDO::OPT_CACHE_EXPIRES] = (integer) $modx->getOption('cache_resource_expires', null, 0);