From a6801928cd36a09d6d231afaa180117d15572bc3 Mon Sep 17 00:00:00 2001 From: Christian Seel Date: Sun, 10 Jan 2016 19:15:30 +0100 Subject: [PATCH 1/3] added new properties for path --- core/components/getpage/snippet.getpage.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/components/getpage/snippet.getpage.php b/core/components/getpage/snippet.getpage.php index 8fbff5a..f4efcc7 100644 --- a/core/components/getpage/snippet.getpage.php +++ b/core/components/getpage/snippet.getpage.php @@ -29,6 +29,9 @@ $properties['pageLastTpl'] = !isset($pageLastTpl) ? "
  • Last
  • " : $pageLastTpl; $properties['pagePrevTpl'] = !isset($pagePrevTpl) ? "
  • <<
  • " : $pagePrevTpl; $properties['pageNextTpl'] = !isset($pageNextTpl) ? "
  • >>
  • " : $pageNextTpl; +$properties['pathUrlSeparator'] = !isset($pathUrlSeparator) ? "/" : $pathUrlSeparator; +$properties['pathNumberSeparator'] = !isset($pathNumberSeparator) ? "-" : $pathNumberSeparator; +$properties['pathHidePageVarKey'] = !isset($pathHidePageVarKey) ? false : $pathHidePageVarKey; $properties['toPlaceholder'] = !empty($toPlaceholder) ? $toPlaceholder : ''; $properties['cache'] = isset($cache) ? (boolean) $cache : (boolean) $modx->getOption('cache_resource', null, false); if (empty($cache_key)) $properties[xPDO::OPT_CACHE_KEY] = $modx->getOption('cache_resource_key', null, 'resource'); From 99e982271fa68799b5d35ca9a7a1e6556e0cf1ee Mon Sep 17 00:00:00 2001 From: Christian Seel Date: Sun, 10 Jan 2016 19:16:12 +0100 Subject: [PATCH 2/3] updated getpage_makeUrl to support the path navScheme --- core/components/getpage/include.getpage.php | 25 +++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/core/components/getpage/include.getpage.php b/core/components/getpage/include.getpage.php index 7280a48..830a299 100644 --- a/core/components/getpage/include.getpage.php +++ b/core/components/getpage/include.getpage.php @@ -39,13 +39,30 @@ function getpage_buildControls(& $modx, $properties) { function getpage_makeUrl(& $modx, $properties, $pageNo, $tpl) { $qs = $properties['qs']; - if ($pageNo === 1) { + $scheme = !empty($properties['pageNavScheme']) ? $properties['pageNavScheme'] : $modx->getOption('link_tag_scheme', $properties, -1); + + if ($properties['pageNavScheme'] === 'path') { + unset($qs[$properties['pageVarKey']]); + $properties['href'] = $modx->makeUrl($modx->resource->get('id'), '', '', $modx->getOption('link_tag_scheme', $properties, -1)); + if ($pageNo !== 1) { + $properties['href'] = rtrim($properties['href'], '/').$properties['pathUrlSeparator']; + if (!$properties['pathHidePageVarKey']) $properties['href'] .= $properties['pageVarKey'].$properties['pathNumberSeparator']; + $properties['href'] .= $pageNo; + } + if (!empty($qs)) $properties['href'] .= '?'. http_build_query($qs); + } else { - $qs[$properties['pageVarKey']] = $pageNo; + + if ($pageNo === 1) { + unset($qs[$properties['pageVarKey']]); + } else { + $qs[$properties['pageVarKey']] = $pageNo; + } + $properties['href'] = $modx->makeUrl($modx->resource->get('id'), '', $qs, $scheme); + } - $scheme = !empty($properties['pageNavScheme']) ? $properties['pageNavScheme'] : $modx->getOption('link_tag_scheme', $properties, -1); - $properties['href'] = $modx->makeUrl($modx->resource->get('id'), '', $qs, $scheme); + $properties['pageNo'] = $pageNo; $nav= $modx->newObject('modChunk')->process($properties, $tpl); return $nav; From cf02d86a85ac5c2810b71179d68ce08040743890 Mon Sep 17 00:00:00 2001 From: Christian Seel Date: Sun, 10 Jan 2016 19:22:47 +0100 Subject: [PATCH 3/3] added new path properties to install script --- _build/properties/properties.getpage.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/_build/properties/properties.getpage.php b/_build/properties/properties.getpage.php index 2695283..987a00c 100644 --- a/_build/properties/properties.getpage.php +++ b/_build/properties/properties.getpage.php @@ -150,7 +150,25 @@ 'type' => 'textfield', 'options' => '', 'value' => '', + ),array( + 'name' => 'pathUrlSeparator', + 'desc' => 'If you use "path" as pageNavScheme this sets the separator between the resources URI and the pagination path.', + 'type' => 'textfield', + 'options' => '', + 'value' => '/', + ),array( + 'name' => 'pathNumberSeparator', + 'desc' => 'Separator between pageVarKey and page number if you use "path" as pageNavScheme.', + 'type' => 'textfield', + 'options' => '', + 'value' => '-', + ),array( + 'name' => 'pathHidePageVarKey', + 'desc' => 'Optionally hide the pageVarKey from the pagination path', + 'type' => 'combo-boolean', + 'options' => '', + 'value' => false, ) ); -return $properties; \ No newline at end of file +return $properties;