processwire-issues
processwire-issues copied to clipboard
Add start as a modifier in InputFieldSelector
Short description of the issue
start
is not available as a modifier within InputFieldSelector
Expected behavior
start
to be available
Actual behavior
it isn't
Optional: Screenshots/Links that demonstrate the issue
Optional: Suggestion for a possible fix
Add start
modifier to line 588 of wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module
https://github.com/theGC/processwire/blob/48092d503e90720df796adb0a5f8bfd3afd84889/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module#L588
'start' => array(
'input' => 'integer',
'label' => $this->_('Start (requires limit)'),
'operators' => array('=')
),
Steps to reproduce the issue
install processwire, add a selector field to a page
Setup/Environment
any
Also worth adjusting renderTestSelector
to allow for the new start modifier:
https://github.com/theGC/processwire/blob/65092e06acd31738122aac95812dfde2b9c9a57f/wire/modules/Inputfield/InputfieldSelector/InputfieldSelector.module#L751
// take into account a limit=n
if(strpos($selector, 'limit=') !== false && preg_match('/\blimit=(\d+)/', $selector, $matches)) {
$out = ' ' . sprintf($this->_('(%d without limit)'), $cnt);
// take into account a start=n
if(strpos($selector, 'start=') !== false && preg_match('/\bstart=(\d+)/', $selector, $startMatches)) {
$cnt -= $startMatches[1];
if($cnt < 0) $cnt = 0;
}
if($cnt > $matches[1]) $cnt = $matches[1];
}
@theGC This one was intentionally left out since it's the current pagination number ($input->pageNum
) that determines and sets the start=
value. The primary public API usage of it is so that you can specify start=0
to override automatic pagination for things like top level navigation that doesn't change on paginations. I wasn't aware there was a use case for having 'start' in this module. Can you describe more about the use case?
yeah sure, we're using it to allow clients to select pages (categories or products), showing a limited set of these, starting at a certain index.
The above is set up within a matrix repeater, I've screengrabbed a sample set up below:
The above allows the user to create blocks of content, with the same selector broken up over 2 or more parts of the page.