We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44754
    • 5 Posts
    I'm working for a shop which also serves dinner with a weekly changing menu. I was building the shop's website with static html at first, but then I thought it would be nice to change the menu automatically at a specified date. So I tried to switch the whole site to MODX Revolution, assuming it'd be easy to get the menu resource replaced by just define an publish-unpublish-date. Of course it is not that easy.

    I guess, getResources could solve my problem to have a weekly changing menu on the homepage. But it won't work.

    To get familiar with Revo I'm following the MODx Revolution for Complete Beginners series on codingpad.maryspad.com
    According to the course, I installed the snippet and made a plain getResources call to make sure the content is getting pulled in. And at first it did, I got the full array which was supposed to show. But once I started to define some parameters, getResources stopped working. I get no answer at all and I can't even imagine what went wrong. Even uninstalling and reinstalling didn't bring the plain array back.

    So my first question is: what might have gone wrong?
    And the second is: do I even need getResources for my purpose? I want to change a part of my homepage (which is a layouted list) automatically on a specified date. Is there a more elegant way?

    Thank you for your patience and your answers.


    • MODX Version: MODX Revolution 2.2.5-pl (traditional)
    • PHP Version: 5.2.17
    • Database (MySQL, SQL Server, etc) Version: MySQL 5.5.28
    • Additional Server Info:
    • Installed MODX Add-ons: Wayfinder, Batcher, getResources

    This question has been answered by multiple community members. See the first response.

      • 22840
      • 1,572 Posts
      How are you calling getResources, what are you trying to call into it ?

      If your adding your menus as TV's then you will need to include the &includeTVs, &processTVs

      http://rtfm.modx.com/extras/revo/getresources

      The more info you can give the easier it will be to solve wink
        • 3109 ☆ A M B ☆
        • 894 Posts
        We need more information besides it won't work.

        What does your getResource call with parameters look like?

        What does your tpl chunk look like?

        You should be able to do something using a Template Variable with a date input type to activate the menu for whatever week you need.

        We need more details in order to help you out.

        Good luck.
          Benjamin Marte
          Interactive Media Developer
          Follow Me on Twitter | Visit my site | Learn MODX
        • discuss.answer
          • 8274 ☆ A M B ☆
          • 222 Posts
          With getResources, you can add a "where" filter parameter to get all the resources by standard resource fields, such as "published".

          <code>
          [[!getResources? &parents=`[[*id]]` &where=`{"published:=":1}` &tpl=`myRowTpl`]]
          </code>

          If you have all your menu resources in a folder, you can set the parent to the id of that folder.

          You can then set the pub date and unpub dates for the menus. This way you have less TVs to process and use existing fields in the resource database record (Processing resources by TVs can get a bit slow since it has to reference a second table for the info).
            • 44754
            • 5 Posts
            Hey, thank you all for your responses, and sorry that I can just now reply.

            Quote from: paulp at Aug 12, 2013, 10:33 AM
            How are you calling getResources, what are you trying to call into it ?
            &Quote from: benmarte at Aug 12, 2013, 10:34 AM
            What does your getResource call with parameters look like?
            What does your tpl chunk look like?
            I just tried to call the plain array to see whether it worked at all. And it did at first, I had the array that showed all properties. But since then I can't even reproduce this array.
            I might concentrate a bit too much on the array, I guess. And I have to admit, that I am a bit challenged by trying to understand MODX.

            Quote from: paulp at Aug 12, 2013, 10:33 AM
            If your adding your menus as TV's then you will need to include the &includeTVs, &processTVs
            &
            Quote from: benmarte at Aug 12, 2013, 10:34 AM
            You should be able to do something using a Template Variable with a date input type to activate the menu for whatever week you need.
            I didn't want to add the menus as TV's because I didn't think they could be published/unpublished by date without publishing/unpublishing the resource I place them in.

            Quote from: paulp at Aug 12, 2013, 10:33 AM
            The more info you can give the easier it will be to solve wink
            &
            Quote from: benmarte at Aug 12, 2013, 10:34 AM
            We need more information besides it won't work.
            I'm working on that smiley I figured out, however, that this might take a little more time. I will, if you allow, come back to my question, when I have more time.

            Quote from: benmarte at Aug 12, 2013, 10:34 AM
            Good luck.
            Thank you smiley
              • 44754
              • 5 Posts
              Quote from: dvstudiosinc at Aug 12, 2013, 02:03 PM
              With getResources, you can add a "where" filter parameter to get all the resources by standard resource fields, such as "published".

              <code>
              [[!getResources? &parents=`[[*id]]` &where=`{"published:=":1}` &tpl=`myRowTpl`]]
              </code>

              If you have all your menu resources in a folder, you can set the parent to the id of that folder.

              You can then set the pub date and unpub dates for the menus. This way you have less TVs to process and use existing fields in the resource database record (Processing resources by TVs can get a bit slow since it has to reference a second table for the info).

              Hah, this sounds like what I planned to do. I will try ist out, thank you.

              EDIT: I tried this and I'm relieved, that I didn't do all wrong. I do not get that selected folder (id is 21) however. My call is now:

              <code>[[!getResources? &showHidden=`1` &parents=`21` &where=`{"published:=":1}` &tpl=`mittag` &limit=`1`]]</code>

              The setting for the folder is published, hidden from menus, container. [ed. note: anderswolf last edited this post 13 years, 2 months ago.]
              • discuss.answer
                • 22840
                • 1,572 Posts
                Again, what are you trying to pull in ?

                If the menus are added as TV's then you need to tell getResources to include them:

                [[!getResources?  &includeTVs=`1` &processTVs=`1` &showHidden=`1` &parents=`21` &where=`{"published:=":1}` &tpl=`mittag` &limit=`1`]]


                If you want to pull in the content of the wysiwyg then you need to include the content:

                [[!getResources?  &includeContent=`1` &showHidden=`1` &parents=`21` &where=`{"published:=":1}` &tpl=`mittag` &limit=`1`]]


                What's in your mittag chunk ?



                  • 44754
                  • 5 Posts
                  Quote from: paulp at Aug 15, 2013, 05:23 AM
                  Again, what are you trying to pull in ?

                  If the menus are added as TV's then you need to tell getResources to include them:

                  [[!getResources?  &includeTVs=`1` &processTVs=`1` &showHidden=`1` &parents=`21` &where=`{"published:=":1}` &tpl=`mittag` &limit=`1`]]


                  If you want to pull in the content of the wysiwyg then you need to include the content:

                  [[!getResources?  &includeContent=`1` &showHidden=`1` &parents=`21` &where=`{"published:=":1}` &tpl=`mittag` &limit=`1`]]


                  What's in your mittag chunk ?

                  Again, thank you for your response. And the patience.
                  I try to pull in a resource that displays an unordered list. That must be the wysiwig then.
                  And to be honest, my mittag-chunk is pretty empty:
                  <div id="menu">[[*content]]</div>

                  I already figured that the call for [[*content]] is wrong here, but I obviously didn't figure out the right call. [ed. note: anderswolf last edited this post 13 years, 2 months ago.]
                  • discuss.answer
                    • 22840
                    • 1,572 Posts
                    Try:

                    <div id="menu">[[+content]]</div>
                      • 44754
                      • 5 Posts
                      Quote from: paulp at Aug 15, 2013, 09:50 AM
                      Try:

                      <div id="menu">[[+content]]</div>

                      Of course! Now it works!
                      Oh, I thank you very much. You were a great help. I'm so glad that I came here smiley