We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13226
    • 953 Posts
    I am trying to get pdoResource to output all pages that use a specific tag found in a TV, to no avail

    My Tag TV is called: myTags and its input option value is: @CHUNK TagOptions - note: I have tried adding the options directly to the TV but that makes no difference

    The TagOptions chunk uses the following format: tag1||tag2||tag3

    My pdo call:
    [[pdoPage? &element=`pdoResources` &elementClass=`modSnippet` &pageVarKey=`page`
    &parents=`3` 
    &depth=`2` 
    &tpl=`List`
    &limit=`15`
    &sortby=`publishedon` 
    &sortdir=`DESC` 
    &showUnpublished=`0`
    &hideContainers=`1`
    &showHidden=`1` 
    &pageLimit=`10` 
    &includeTVs=`myTags` 
    &processTVs=`1` 
    &tvFilters=`myTags==[[*longtitle]]` 
    &tplPageWrapper=`@INLINE <ul>[[+prev]][[+pages]][[+next]]</ul>` 
    &tplPageActive=`@INLINE <li class="active">[[+pageNo]]</li>` 
    &tplPagePrev=`@INLINE <li class="prev"><a href="[[+href]]">« Previou</a></li>` 
    &tplPagePrevEmpty=`@INLINE <li class="prev">« Previous</li>`
    &tplPageFirst=`@INLINE <li class="first"><a href="[[+href]]">«</a></li>` 
    &tplPageFirstEmpty=`@INLINE <li class="first active">«</li>` 
    &tplPageNext=`@INLINE <li class="next"><a href="[[+href]]">Next »</a></li>` 
    &tplPageNextEmpty=`@INLINE <li class="next">Next »</li>` 
    &tplPageLast=`@INLINE <li class="last"><a href="[[+href]]">»</a></li>` 
    &tplPageLastEmpty=`@INLINE <li class="last active">»</li>` 
    &tplPageSkip=`@INLINE <li class="active">...</li>`
    ]]
    
    [[+page.nav]]


    As can be seen from the above, the filter for the tag uses the longtitle TV. It is this way simply because all tags have their own bespoke page.

    Any help is welcome and appreciated [ed. note: iusemodx last edited this post 8 years, 3 months ago.]
      • 4172
      • 5,888 Posts
      you are searching for Resources, where only a part of the value (if there are multiple selected) matches the search-term, right?

      so try:

      &tvFilters=`myTags==%[[*longtitle]]%` 
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 13226
        • 953 Posts
        Thanks Bruno, at a glimpse that seems to have done the job.

        I will carry out some tests in the morning and report back.

        I have now tested the code and it all seems to work - I have cross referenced the results with the Evo site and it all seems to be right, so thanks again Bruno [ed. note: iusemodx last edited this post 8 years, 3 months ago.]
          • 13226
          • 953 Posts
          What I am experiencing that doesn't work is the count display.

          I have the following:
          <p>Page [[+start]] of [[+pageCount]] with [[+total]] results</p>


          The start and pagecount placeholders are working correctly, but the "total" displays the total amount of files in the parents folder - not the amount that are in the results

          Example:

          Tag1 is used by 100 posts

          The results page displays 20 per page

          The pagination displays: Previous 1 2 3 4 5 Next

          The results depending on which page you are should then look something like: Page 1 of 5 with 100 results

          Instead, I get something like this: Page 1 of 5 with 500 results

          In this case 500 would be the total of documents declared in the parent (3) at the depth (2) specified
            • 4172
            • 5,888 Posts
            [[+total]] doesn't return the count of the results, but does allways return the total-count

            There isn't a placeholder, which returns the count of the current results.
            As workarround, with an additional snippet-call with &return=`ids` you can return the ids and count them.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 13226
              • 953 Posts
              Thanks Bruno

              I am not a PHPr so wouldn't know where to start smiley
                • 4172
                • 5,888 Posts
                This is a untested snippet 'pdoResourcesWithCount'

                <?php
                
                $output = $modx->runSnippet('pdoResources',$scriptProperties);
                
                $scriptProperties['return'] = 'ids';
                
                $ids = $modx->runSnippet('pdoResources',$scriptProperties);
                
                $count = 0;
                if (!empty($ids)){
                    $ids = explode(',',$ids);
                    $count = count($ids);
                }
                
                $modx->setPlaceholder('results_count',$count);
                
                return $output;
                


                [[pdoPage? &element=`pdoResourcesWithCount` &elementClass=`modSnippet` &pageVarKey=`page`
                &parents=`3` 
                &depth=`2` 
                &tpl=`List`
                &limit=`15`
                &sortby=`publishedon` 
                &sortdir=`DESC` 
                &showUnpublished=`0`
                &hideContainers=`1`
                &showHidden=`1` 
                &pageLimit=`10` 
                &includeTVs=`myTags` 
                &processTVs=`1` 
                &tvFilters=`myTags==[[*longtitle]]` 
                &tplPageWrapper=`@INLINE <ul>[[+prev]][[+pages]][[+next]]</ul>` 
                &tplPageActive=`@INLINE <li class="active">[[+pageNo]]</li>` 
                &tplPagePrev=`@INLINE <li class="prev"><a href="[[+href]]">« Previou</a></li>` 
                &tplPagePrevEmpty=`@INLINE <li class="prev">« Previous</li>`
                &tplPageFirst=`@INLINE <li class="first"><a href="[[+href]]">«</a></li>` 
                &tplPageFirstEmpty=`@INLINE <li class="first active">«</li>` 
                &tplPageNext=`@INLINE <li class="next"><a href="[[+href]]">Next »</a></li>` 
                &tplPageNextEmpty=`@INLINE <li class="next">Next »</li>` 
                &tplPageLast=`@INLINE <li class="last"><a href="[[+href]]">»</a></li>` 
                &tplPageLastEmpty=`@INLINE <li class="last active">»</li>` 
                &tplPageSkip=`@INLINE <li class="active">...</li>`
                ]]
                
                [[+results_count]]
                 
                [[+page.nav]]
                

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

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 13226
                  • 953 Posts
                  WOW

                  Tested - it outputs the current pages count

                  ?page=1: 20
                  ?page=2: 20
                  ?page=3: 15
                  Etc.

                  Not the full count e.g 45
                    • 13226
                    • 953 Posts
                    Bruno, I am open for a commercial solution if you have the time - please let me know
                      • 13226
                      • 953 Posts
                      @ Bruno - have sent you a PM

                      Just for clarity:

                      The end sum of results should be shown, so if the amount of posts using tag1 is 100, the result should be shown as 100

                      At the moment the script counts the amount on a "per page" basis, it doesnt count all of the posts

                      The page should always show the full amount, example:

                      domain.com/tags/tagname
                      Page 1 of 5 with 100 results

                      domain.com/tags/tagname?page=2
                      Page 2 of 5 with 100 results

                      domain.com/tags/tagname?page=2
                      Page 3 of 5 with 100 results

                      Etc.