@@ -458,10 +458,15 @@ public function renderFaqsByCategoryId(int $categoryId, string $orderBy = 'id',
458458 * @param int[] $faqIds Array of record ids
459459 * @param string $orderBy Order by
460460 * @param string $sortBy Sort by
461+ * @param bool $usePagination Whether to use internal pagination
461462 * @throws CommonMarkException
462463 */
463- public function renderFaqsByFaqIds (array $ faqIds , string $ orderBy = 'fd.id ' , string $ sortBy = 'ASC ' ): array
464- {
464+ public function renderFaqsByFaqIds (
465+ array $ faqIds ,
466+ string $ orderBy = 'fd.id ' ,
467+ string $ sortBy = 'ASC ' ,
468+ bool $ usePagination = true
469+ ): array {
465470 $ records = implode (', ' , $ faqIds );
466471 $ page = Filter::filterInput (INPUT_GET , 'seite ' , FILTER_VALIDATE_INT , 1 );
467472
@@ -530,21 +535,20 @@ public function renderFaqsByFaqIds(array $faqIds, string $orderBy = 'fd.id', str
530535 $ num = $ this ->configuration ->getDb ()->numRows ($ result );
531536 $ numberPerPage = $ this ->configuration ->get ('records.numberOfRecordsPerPage ' );
532537
533- if ($ page == 1 ) {
534- $ first = 0 ;
535- } else {
536- $ first = ($ page * $ numberPerPage ) - $ numberPerPage ;
537- }
538+ $ first = $ usePagination && $ page > 1 ? ($ page * $ numberPerPage ) - $ numberPerPage : 0 ;
538539
539540 $ searchResults = [];
540541 if ($ num > 0 ) {
541542 $ counter = 0 ;
542543 $ displayedCounter = 0 ;
543544 $ lastFaqId = 0 ;
544545 $ faqHelper = new FaqHelper ($ this ->configuration );
545- while (($ row = $ this ->configuration ->getDb ()->fetchObject ($ result )) && $ displayedCounter < $ numberPerPage ) {
546+ while (
547+ ($ row = $ this ->configuration ->getDb ()->fetchObject ($ result )) &&
548+ (!$ usePagination || $ displayedCounter < $ numberPerPage )
549+ ) {
546550 ++$ counter ;
547- if ($ counter <= $ first ) {
551+ if ($ usePagination && $ counter <= $ first ) {
548552 continue ;
549553 }
550554
0 commit comments