We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43939
    • 19 Posts
    I just learned how to display Most read news items. And the next step on my journey is to show most interesting news items using the same snippet HitsPage. I have several parent resource documents (Menu Item 1, Menu Item2, Menu Item 3) showing on my main menu. Basically, I would like to create a hidden parent resource called "Interesting" and whenever I create a new Document resource, which is a child of one of the main menu items (Menu Item 1, Menu Item2, Menu Item 3), I'd also make it a child of Interesting parent resource. So that I can call getResources with the parent id of Interesting to pull most interesting documents from my whole website. Does it make sense? Is that possible? Is there any other way to accomplish it? Thank you. MODx is great and so are you guys smiley
      • 3749
      • 24,544 Posts
      Resources can only have one parent, but you can set &parents=`0` if you want to include all Resources on the site in the search or &parents=`2,4,6` to search as many parent folders as you like.
        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
        • 43939
        • 19 Posts
        The problem is I do not want to create the same document resource twice in two containers/parents. Yet, I need a container/ parent containing most interesting documents to find out most viewed one using getResources and HitsPage. Maybe, it is not easy for me.
          • 3749
          • 24,544 Posts
          I don't think you do need that. As long as all the documents are under the specified parent(s), the getResources tag should select and display the three most visited pages from all of them.

          You shouldn't need a separate container with the most interesting documents, unless you need that for some other reason. If you do, you can make the resources under it weblinks and leave it out of the &parents list.
            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
            • 4172
            • 5,888 Posts
            you can add a checkbox-TV 'interesting' to your resources.
            Than getResources can filter by that TV.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 3749
              • 24,544 Posts
              Bruno, as I understand it, the OP is defining "interesting" on the basis of the number of hits the page has received (in the HitsPage TV), so he shouldn't need another TV.
                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
                • 4172
                • 5,888 Posts
                I see.
                Does HitsPage store the hits into a TV?
                Than you can of course just sortby by this hits-TV.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  HitsPage can store into a TV if the HitsPage snippet is used in the template or the resource content:
                  [[!HitsPage? &saveTv=`true`]]

                  There are a couple of bits of the code that could be improved.

                  It specifically requires a TV named "HitsPage"; this could instead use the actual value of the saveTv property being the name of the TV to use.

                  It also specifically checks for a property value of 'true', rather than simply checking to make sure it's set to a true value.

                  If the property saveTv is not set to "true", then only the resource properties is set (as a JSON string). This is the only use I have yet noticed of resource properties; that's interesting.

                  The snippet returns the value, either of the TV if used or of the resource property. So if this is used in such a way to only increment the count but not display it, you would need to hide the output in some way, in an HTML element with display:none perhaps.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 43939
                    • 19 Posts
                    I think I will need to understand how to use weblinks now, and then get back here. Thank you all for responding. I am a girl by the way wink
                      • 9207 ☆ A M B ☆
                      • 2,475 Posts
                      I think this is really more of a data model problem... you want to cherry-pick resources into a group so you can refer to them collectively (e.g. most popular, etc). This is where we need a MODX resource taxonomy plugin... all the suggestions here are valid, it's just a matter of the UI you prefer.