We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33982 ☆ A M B ☆
    • 476 Posts
    I'm using the newest version of MODx (2.2.4-pl) and the newest version of getResources (1.5.0). I've currently got a portfolio on a site I'm building where we're showing 3 of the newest projects in our portfolio. But the client wants the ability to label any of the projects as featured that they want. The way I currently have this setup on the page is using getResources and I'm listing the 3 newest projects based on publication date. But if a project is tagged as "featured", I need for that project to stay in the listing of the 3 projects on our portfolio page even if it's not the newest (in other words, even if there were many new projects, it would not get bumped from the list of 3).

    I created a TV named "our_work_featured" with Input Option Values of "Yes==1||No==0". The input type is "Radio". So on the modx document, the manager will choose "Yes" if they want it featured. No problem so far. The challenge is trying to use "tvFilters" to return the "featured" article in the results as well as showing the other projects even if they're not labeled as "featured". So for example, I have 10 projects, I want to show the newest 3. If one of those 10 projects is tagged with the TV listed above as "featured", I want that document to show up in the result even if it was the oldest document.

    Hopefully that makes sense.
      Precision Web Development ... SmashStack.com
      • 4172
      • 5,888 Posts
      you can create a wrapper-snippet, which first gets the featured resources and counts them. Then get the limited count of newest resources by getResources.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 33982 ☆ A M B ☆
        • 476 Posts
        Quote from: Bruno17 at Aug 23, 2012, 05:08 PM
        you can create a wrapper-snippet, which first gets the featured resources and counts them. Then get the limited count of newest resources by getResources.

        Hey Bruno17, thanks for the response. Any suggestions on that first wrapper-snippet? Is there anything out there that returns the count on something like this or would this need to be custom written?
          Precision Web Development ... SmashStack.com
          • 4172
          • 5,888 Posts
          I think something like that should work. (Untested)

          [[!getFeatured? &tpl=`myTpl` &parents=`999` &limit=`3`]]
          


          <?php
          //[[!getFeatured? &tpl=`myTpl` &parents=`999` &limit=`3`]]
          
          $properties = $scriptProperties;
          $properties['tvFilters'] = 'our_work_featured==1';
          $output = $modx->runSnippet('getResources',$properties);
          
          $scriptProperties['limit'] = $scriptProperties['limit'] - $modx->getPlaceholder('total');
          $output .= $modx->runSnippet('getResources',$scriptProperties);
          
          return $output;   
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 33982 ☆ A M B ☆
            • 476 Posts
            Thanks Bruno17 so much for the response!

            So I created a snippet with the above code. Seems to have a few kinks in it.

            So if I had set "No" to the featured TV radio options to the most 3 newest documents added in the "Portfolio" container, they all showed up fine. If on the most recent document I choose "Yes" as a featured document, the 3 documents would show up in the results plus the newest document again (thus 4 would show up in the output). If I go to older portfolio items (for example 3 of them) and set them to be featured, they also get added on as well in addition to the 3 most recent documents added in the portfolio section (now bringing a total of 6)...getResources essentially ignores the value passed in as "limit".

            Got any ideas why this is happening? [ed. note: flinx777 last edited this post 14 years, 1 month ago.]
              Precision Web Development ... SmashStack.com