We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21078
    • 77 Posts
    Hello community,

    I have "Articles" installed and want to get an overview including a pagination. First I tried it without getPage/getResources and instead used the Articles way of retrieving the resources. I discovered that after activating pagination, the links get mixed up. So I used getPage/getResources but same result. It's pretty strange - all other placeholder like [+pagetitle] or [+introtext] etc. are correct, only [+id] returns not the right page ID (returns IDs from all over the documents, not only children of the given parent) which ends up in wrong links. When I switch back using no pagination everything is fine.

    Here is my code:

    [[!getPage?
        &elementClass=`modSnippet`
        &element=`getResources`
        &parents=`[[*id]]`
        &depth=`1`
        &showHidden=`1`
        &includeTVs=`1`
        &processTVs=`1`
        &limit=`9`
        &pageVarKey=`page`
        &tpl=`dpp_v2.ArticleRowTpl`
        &pageNavOuterTpl
    ]]
    [[!+page.nav:notempty=`
    <ul class="paging">
        [[!+page.nav]]
    </ul>
    `]]


    And the chunk for "dpp_v2.ArticleRowTpl":

    <div class="col-xs-12 col-sm-6 col-md-4">
        <div class="thumbnail">
            <img src="[[!phpthumbof? &input=`/assets/gallery/[[!getGalleryAlbumCover? &id=`[[+tv.galleryAlbum]]`]]` &options=`&w=345&h=345&zc=1&q=80`]]" alt="Thumbnail" class="img-responsive">
            <div class="caption">
                <h3>[[+pagetitle:lcase]]</h3>
                <p>[[+introtext:lcase]]</p>
                <p class="center-block"><a href="[[~[[+id]]]]" class="plus-btn">plus</a></p>
            </div>
        </div>
    </div>


    Any ideas??

    This question has been answered by Bruno17. See the first response.

      L.net Web Solutions
      Professional webdesign and development with MODX and WordPress.
      • 21078
      • 77 Posts
      Update on this issue:
      I have the same problem while not using getPage but calling getResources in combination with "&tvFilters" and getUrlParam.

      [[!getResources?
          &parents=`[[*id]]`
          &depth=`1`
          &showHidden=`1`
          &includeTVs=`1`
          &includeTVList=`galleryAlbum`
          &processTVs=`1`
          &tvFilters=`articlestags==%[[!getUrlParam? &name=`kategorie`]]%`
          &limit=`99`
          &pageVarKey=`page`
          &tpl=`dpp_v2.ArticleRowTpl`
      ]]


      When I call this code cached, the links / ids are correct but of course the parameter doesn't work. sad
        L.net Web Solutions
        Professional webdesign and development with MODX and WordPress.
        • 3749
        • 24,544 Posts
        As you probably know, calling getUrlParam cached delays the processing so it's not available at the time getResources needs it.

        The only solution I can think of is to modify the getUrlParm code to set a placeholder rather than returning a value. Then call getUrlParm uncached above the getResources tag and use the placeholder (cached) in the &tvFilter property. I'm not sure it would work, but I think it will.

        Put this tag above the getResources tag:

        [[!getUrlParam? &name=`kategorie`]]


        In the getUrlParamSnippet, change this:

        return $output;


        to this:

        $modx->setPlaceholder('url_param', $output);
        return '';


        Us this in the getResources tag:

         &tvFilters=`articlestags==%[[+url_param]]%`
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 21078
          • 77 Posts
          Hi Bob,

          thank you for your reply. I tried it but same result sad But I figured out, this behaviour also appears while simply calling getResources uncached ... so I broke down the snippet call without URL parameters etc. to this working version:

          [[getResources?
              &parents=`[[*id]]`
              &depth=`1`
              &showHidden=`1`
              &includeTVs=`1`
              &includeTVList=`galleryAlbum`
              &processTVs=`1`
              &limit=`99`
              &pageVarKey=`page`
              &tpl=`dpp_v2.ArticleRowTpl`
          ]]


          But when I call the same code uncached like the following, IDs are mixed up again:

          [[!getResources?
              &parents=`[[*id]]`
              &depth=`1`
              &showHidden=`1`
              &includeTVs=`1`
              &includeTVList=`galleryAlbum`
              &processTVs=`1`
              &limit=`99`
              &pageVarKey=`page`
              &tpl=`dpp_v2.ArticleRowTpl`
          ]]
            L.net Web Solutions
            Professional webdesign and development with MODX and WordPress.
            • 4172
            • 5,888 Posts
            what happens with a very simple tpl-chunk, just

            [[+id]]<br />


            what's the code of getGalleryAlbumCover?

            And I see no reason to call that part uncached, so try to call that cached:

            [[phpthumbof? &input=`/assets/gallery/[[getGalleryAlbumCover? &id=`[[+tv.galleryAlbum]]`]]` &options=`&w=345&h=345&zc=1&q=80`]]


              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 21078
              • 77 Posts
              Ok! Simple output of [[+id]] works! So maybe the bug is somewhere in getGalleryAlbumCover ... here is the snippet code:

              //getGalleryAlbumCover
              $output = '';
              $sql = "select * from modx_gallery_albums mga where mga.id = $id";
              $album = $modx->query($sql);
              if (!is_object($album)) {
                  return;
              }
              $data = $album->fetch(PDO::FETCH_ASSOC);
              $modx->toPlaceholders($data);
              $output = $data['cover_filename'];
              return $output;
                L.net Web Solutions
                Professional webdesign and development with MODX and WordPress.
              • discuss.answer
                • 4172
                • 5,888 Posts
                this line produces the issue:

                $modx->toPlaceholders($data);


                this is setting placeholders for all columns of the gallery-album-record, also the id of the gallery-album into the placeholder [[+id]]

                modify it like that:

                //getGalleryAlbumCover
                $toPlaceholders = $modx->getOption('toPlaceholders',$scriptProperties,'1');
                $output = '';
                $sql = "select * from modx_gallery_albums mga where mga.id = $id";
                $album = $modx->query($sql);
                if (!is_object($album)) {
                    return;
                }
                $data = $album->fetch(PDO::FETCH_ASSOC);
                if (!empty($toPlaceholders)){
                    $modx->toPlaceholders($data);
                }
                $output = $data['cover_filename'];
                return $output;


                and call it like that:

                [[getGalleryAlbumCover? &toPlaceholders=`0` &id=`[[+tv.galleryAlbum]]`]]
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 21078
                  • 77 Posts
                  Perfect! Now it's working! smiley I will try paging again with getPage later, but I guess that'll work too now.
                  Thanks a lot!! smiley
                    L.net Web Solutions
                    Professional webdesign and development with MODX and WordPress.
                    • 3749
                    • 24,544 Posts
                    Great catch Bruno. smiley
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting