Open michaellenaghan opened 5 months ago
$page->url() produces incorrect URLs for some parameters
$page->url()
See the examples below, but basically: $page->url() should produce the same output as $input->url().
$input->url()
In my home page template:
$input->url() produces correct URLs:
$input->url(['pageNum' => 2])
$page->url() does not:
$page->url(2) returns "/page2/"
$page->url(2)
$page->url('-') returns "/-/" on page 1
$page->url('-')
$page->url('+') returns "/-/page2/" on page 1
$page->url('+')
$page->url(['pageNum' => '+']) returns "/page2/" on page 1
$page->url(['pageNum' => '+'])
$page->url('-') returns "/-/" on page 2
$page->url('+') returns "/-/page3/" on page 2
$page->url(['pageNum' => '+']) returns "/page3/" on page 2
Note that:
'/-'
'-'
'+'
The issues are fairly straightforward.
For example, this line:
'urlSegmentStr' => is_string($options) ? $options : '',
should be changed to something like this:
'urlSegmentStr' => (is_string($options) && !in_array($options, array('+', '-'))) ? $options : '',
and this line:
if($template->slashPageNum) $url .= '/';
if($template->slashPageNum === 1) $url .= '/';
(When "Should page number URLs have a trailing slash?" is set to "No", $template->slashPageNum is set to -1, a truthy value.)
$template->slashPageNum
In a template:
In the code for the template:
Short description of the issue
$page->url()
produces incorrect URLs for some parametersExpected behavior
See the examples below, but basically:
$page->url()
should produce the same output as$input->url()
.Actual behavior
In my home page template:
$input->url()
produces correct URLs:$input->url(['pageNum' => 2])
returns "/page2"$page->url()
does not:$page->url(2)
returns "/page2/"$page->url('-')
returns "/-/" on page 1$page->url('+')
returns "/-/page2/" on page 1$page->url(['pageNum' => '+'])
returns "/page2/" on page 1$page->url('-')
returns "/-/" on page 2$page->url('+')
returns "/-/page3/" on page 2$page->url(['pageNum' => '+'])
returns "/page3/" on page 2Note that:
$page->url()
is prepending'/-'
when'-'
and'+'
are passed in (but not when they're passed in via options!)$page->url()
is appending slashes when it shouldn'tOptional: Suggestion for a possible fix
The issues are fairly straightforward.
For example, this line:
should be changed to something like this:
and this line:
should be changed to something like this:
(When "Should page number URLs have a trailing slash?" is set to "No",
$template->slashPageNum
is set to -1, a truthy value.)Steps to reproduce the issue
In a template:
In the code for the template:
$page->url('+')
Setup/Environment