pdoPage Returning Unformatted Array

I am switching to pdoPage from getPage and when I try to use pdoPage it only outputs all of the data in a raw array. I have tried using a property set as well as inline properties in the snippet call and I get the same output. Here is my snippet call. Thanks for any assistance, I’m stumped.

Using a property set:

[[!pdoPage@pdoEvents?
    &element=`pdoResources`
    &parents=`[[*id]]`
    &limit=`8`
]]
[[!+page.nav]]

Without a property set. Exact same parameters as in the property set. All other parameters in the property set remained unchanged from default.

[[!pdoPage?
    &element=`pdoResources`
    &parents=`[[*id]]`
    &limit=`8`
    &tplPage=`@INLINE <li class="page-item disabled"><a[[+title]] href="[[+href]]">[[+pageNo]]</a></li>`
    &tplPageWrapper=`@INLINE <nav aria-label="Pagination"><ul class="pagination pagination-lg justify-content-center">[[+prev]][[+pages]][[+next]]"</ul></nav>`
    &tplPageActive=`@INLINE <li class="page-item active"><a [[+title]] href="[[+href]]">[[+pageNo]]</a></li>`
    &tplPageFirst=`@INLINE <li class="page-item"><a class="page-link" href="[[+href]]">First</a></li>`
    &tplPageLast=`@INLINE <li class="page-item"><a class="page-link" href="[[+href]]">Last</a></li>`
    &tplPagePrev=`@INLINE <li class="page-item"><a class="page-link" href="[[+href]]">&laquo;</a></li>`
    &tplPageNext=`@INLINE <li class="page-item"><a class="page-link" href="[[+href]]">&raquo;</a></li>`
    &tplPageFirstEmpty=`@INLINE <li class="page-item disabled"><a class="page-link" href="[[+href]]">First</a></li>`
    &tplPageLastEmpty=`@INLINE <li class="page-item disabled"><a class="page-link" href="[[+href]]">Last</a></li>`
    &tplPagePrevEmpty=`@INLINE <li class="page-item disabled"><a class="page-link" href="[[+href]]">&laquo;</a></li>`
    &tplPageNextEmpty=`@INLINE <li class="page-item disabled"><a class="page-link" href="[[+href]]">&raquo;</a></li>`
]]
[[!+page.nav]]

PART of the output (it’s a lot)

Array
(
    [plPrefix] => 
    [maxLimit] => 100
    [page] => 1
    [pageVarKey] => page
    [pageLimit] => 5
    [element] => pdoResources
    [pageNavVar] => page.nav
    [pageCountVar] => pageCount
    [pageLinkScheme] => 
    [tplPage] => @INLINE <li class="page-item"><a[[+title]] href="[[+href]]">[[+pageNo]]</a></li>
    [tplPageWrapper] => @INLINE <nav aria-label="Pagination"><ul class="pagination pagination-lg justify-content-center">[[+prev]][[+pages]][[+next]]"</ul></nav>
    [tplPageActive] => @INLINE <li class="page-item active"><a [[+title]] href="[[+href]]">[[+pageNo]]</a></li>
    [tplPageFirst] => @INLINE <li class="page-item"><a class="page-link" href="[[+href]]">pdopage_first</a></li>
    [tplPageLast] => @INLINE <li class="page-item"><a class="page-link" href="[[+href]]">pdopage_last</a></li>
    [tplPagePrev] => @INLINE <li class="page-item"><a class="page-link" href="[[+href]]">&laquo;</a></li>
    [tplPageNext] => @INLINE <li class="page-item"><a class="page-link" href="[[+href]]">&raquo;</a></li>
    [tplPageSkip] => @INLINE <li class="page-item disabled"><span class="page-link">...</span></li>
    [tplPageFirstEmpty] => @INLINE <li class="page-item disabled"><a class="page-link" href="[[+href]]">pdopage_first</a></li>
    [tplPageLastEmpty] => @INLINE <li class="page-item disabled"><a class="page-link" href="[[+href]]">pdopage_last</a></li>
    [tplPagePrevEmpty] => @INLINE <li class="page-item disabled"><a class="page-link" href="[[+href]]">&laquo;</a></li>
    [tplPageNextEmpty] => @INLINE <li class="page-item disabled"><a class="page-link" href="[[+href]]">&raquo;</a></li>
    [cache] => 
    [cacheTime] => 3600
    [cacheAnonymous] => 
    [ajax] => 
    [ajaxMode] => 
    [ajaxElemWrapper] => #pdopage
    [ajaxElemRows] => #pdopage .rows
    [ajaxElemPagination] => #pdopage .pagination
    [ajaxElemLink] => #pdopage .pagination a
    [ajaxElemMore] => #pdopage .btn-more
    [ajaxTplMore] => @INLINE <button class="btn btn-primary btn-more">[[%pdopage_more]]</button>
    [ajaxHistory] => 
    [setMeta] => 1
    [strictMode] => 1
    [request] => Array
        (
            [q] => events/
        )

You have to define the &tpl property for the pdoResources snippet.
Otherwise the code just outputs the raw data (which can sometimes be helpful to see what placeholders are available in the template-chunk).

Well this is embarrassing, I didn’t realize quite how the snippet worked. I got the listing of events to work properly, but the pagination still doesn’t show. I don’t have enough posts to actually paginate, but I still want it visible even then.

[[!pdoPage?
    &element=`pdoResources`
    &parents=`[[*id]]`
    &limit=`8`
    &tplPage=`@INLINE <li class="page-item disabled"><a[[+title]] href="[[+href]]">[[+pageNo]]</a></li>`
    &tplPageWrapper=`@INLINE <nav aria-label="Pagination"><ul class="pagination pagination-lg justify-content-center">[[+prev]][[+pages]][[+next]]"</ul></nav>`
    &tplPageActive=`@INLINE <li class="page-item active"><a [[+title]] href="[[+href]]">[[+pageNo]]</a></li>`
    &tplPageFirst=`@INLINE <li class="page-item"><a class="page-link" href="[[+href]]">First</a></li>`
    &tplPageLast=`@INLINE <li class="page-item"><a class="page-link" href="[[+href]]">Last</a></li>`
    &tplPagePrev=`@INLINE <li class="page-item"><a class="page-link" href="[[+href]]">&laquo;</a></li>`
    &tplPageNext=`@INLINE <li class="page-item"><a class="page-link" href="[[+href]]">&raquo;</a></li>`
    &tplPageFirstEmpty=`@INLINE <li class="page-item disabled"><a class="page-link" href="[[+href]]">First</a></li>`
    &tplPageLastEmpty=`@INLINE <li class="page-item disabled"><a class="page-link" href="[[+href]]">Last</a></li>`
    &tplPagePrevEmpty=`@INLINE <li class="page-item disabled"><a class="page-link" href="[[+href]]">&laquo;</a></li>`
    &tplPageNextEmpty=`@INLINE <li class="page-item disabled"><a class="page-link" href="[[+href]]">&raquo;</a></li>`
    &showHidden=`1`
    &sortby=`event_start_datetime`
    sortdirTV=`asc`
    &includeTVs=`eventAddress,eventButton,eventCity,eventEndDatetime,eventImage,eventLocationName,eventName,eventOrganizers,eventPrice,eventStartDatetime,eventState,eventZipcode`
    &processTVs=`1`
    &tvPrefix=`tv.`
    &processTVs=`1`
    &includeContent=`1`
    &tpl=`eventSingleRowTpl`
]]

[[!+page.nav]]

Why? And what do you want to show, if there is only one page?


As far as I can tell, you’d have to change the snippet code (or rather duplicating the snippet and adjusting the code) to show an output, if there is only one result page.

It looks better to have the pagination at the bottom, even if all the buttons are greyed out/disabled. Really thats it.

The best solution is probably to change the tplPageWrapper content. [[+prev]], [[+pages]] and [[+next]] will all be empty, if there is only one page. So maybe use an output modifier to output something.


You could also duplicate the snippet pdoPage, make some changes to the duplicated snippet and then use the duplicated snippet instead of pdoPage, but I wouldn’t advice doing that.

Here is the part in the code where [[+prev]], [[+pages]] etc. are set, when there is only one page:

Ised [[+pages:isempty=``]] and that worked beautifully. Thanks!

Also, you have to be very careful with inline templates and output modifiers:

Code like this won’t work,

[[!pdoPage?
	...
	&tplPageWrapper=`@INLINE ...[[+pages:isempty=`is empty`]]...`
]]

because the inline template gets parsed before pdoPage runs, so [[+pages]] is always empty.


You could either change the square brackets ([[) to curly brackets ({{)

[[!pdoPage?
	...
	&tplPageWrapper=`@INLINE ...{{+pages:isempty=`is empty`}}...`
]]

to avoid the issue.
(The curly brackets are ignored by the MODX parser and only get converted to square brackets inside pdoPage.)

Or you could just use a normal chunk:

[[!pdoPage?
	...
	&tplPageWrapper=`myTplPageWrapper`
]]

Chunk “myTplPageWrapper”:

<nav>
...[[+pages:isempty=`is empty`]]...
</nav>