<![CDATA[ getPage: cannot get offset and total to work - MODX Community Forums]]> https://forums.modx.com/thread/?thread=72386 <![CDATA[Re: getPage: cannot get offset and total to work]]> https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-549907 Quote from: designcouch at Oct 28, 2015, 10:30 AM
@michelle84, I combined your solution and Jason's - changed that line to:
$properties['offset'] = (!empty($properties['limit']) && !empty($properties['page'])) ? ($properties['limit'] * ($properties['page'] - 1)) + $initialOffset : 0;

and then included this in my getPage call:
$initialOffset=`1`

This allows you to customize the offset per call instead of hard coding it into the snippet. I don't see any reason why this couldn't VERY easily have been added to getPage by now - Jason?

How is this now core functionality smiley Thankfully Google + this forum helped solve my issue smiley]]>
mayhemchaos Apr 06, 2017, 02:17 AM https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-549907
<![CDATA[Re: getPage: cannot get offset and total to work]]> https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-533774
$properties['offset'] = (!empty($properties['limit']) && !empty($properties['page'])) ? ($properties['limit'] * ($properties['page'] - 1)) + $initialOffset : 0;

and then included this in my getPage call:
$initialOffset=`1`

This allows you to customize the offset per call instead of hard coding it into the snippet. I don't see any reason why this couldn't VERY easily have been added to getPage by now - Jason?]]>
designcouch Oct 28, 2015, 10:30 AM https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-533774
<![CDATA[Re: getPage: cannot get offset and total to work]]> https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-432900 It requires a change in the getPage snippet.
Around line 16, change the code to:
$properties['offset'] = (!empty($properties['limit']) && !empty($properties['page'])) ? ($properties['limit'] * ($properties['page'] - 1)) + 1 : 0;


For me, only one resource had to be skipped, that's why I added + 1. I guess you could add more here to skip more resources.

Don't know if this is the best way to achieve this and will test more if it really works as expected.]]>
michelle84 Aug 11, 2012, 05:43 AM https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-432900
<![CDATA[Re: getPage: cannot get offset and total to work]]> https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-432894 michelle84 Aug 11, 2012, 04:54 AM https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-432894 <![CDATA[Re: getPage: cannot get offset and total to work]]> https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-405025 designcouch Dec 28, 2011, 11:55 AM https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-405025 <![CDATA[Re: getPage: cannot get offset and total to work]]> https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-402772 Quote from: thorjarle at Dec 08, 2011, 02:47 PM
How could I then trim away five results so that it will show all the other resources?
You would need to exclude them from the total via where conditions for getResources or something, or we would need to add an initial offset feature to getPage so it could handle the calculations differently.]]>
opengeek Dec 08, 2011, 09:29 AM https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-402772
<![CDATA[Re: getPage: cannot get offset and total to work]]> https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-402766 thorjarle Dec 08, 2011, 08:47 AM https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-402766 <![CDATA[Re: getPage: cannot get offset and total to work]]> https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-402758 opengeek Dec 08, 2011, 08:23 AM https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-402758 <![CDATA[getPage: cannot get offset and total to work]]> https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-402752
  $output = $modx->runSnippet('getPage', array(
    'elementClass' => 'modSnippet',
    'element' => 'getResources',
    'parents' => $sid,
    'limit' => 5,
    'depth' => 1,
    'pageVarKey' => 'page',
    'totalVar' => 'total',
    'offset' => 5,
    'tpl' => 'tpl-Under-Side-Liste-Item',
    'showHidden' => 1,
    'pageFirstTpl' => '<li class="control"><a[[+classes]][[+title]] href="[[+href]]">Første</a></li>',
    'pageLastTpl' => '<li class="control"><a[[+classes]][[+title]] href="[[+href]]">Siste</a></li>',
    'pageNavOuterTpl' => '[[+prev]][[+pages]][[+next]]',
    'pageActiveTpl' => '<li[[+activeClasses]]>[[+pageNo]]</li>',
    'includeTVs' => 1
  ));
]]>
thorjarle Dec 08, 2011, 07:39 AM https://forums.modx.com/thread/72386/getpage-cannot-get-offset-and-total-to-work#dis-post-402752