We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42153 ☆ A M B ☆
    • 27 Posts
    I understand Susan. Thing is i don't want MIGX to show the actual datefield. Not when adding a new MIGX item, nor on my overview on the TV tab of my resource. But I do need it to add the date 'behind the scenes' so to speak.

    What i want to achieve is an overview of the latest items that were added to multiple resources to show on my homepage.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The preview grid only displays the fields you specify, so it's easy enough to simply not put the date/time field in the grid configuration.

      I suspect that there might be a way to insert a timestamp in the JSON string for each item through the Configuration since it's all Javascript, but I have no idea how it would be done. However, hiding it in the formtabs might not be such a good idea. Inevitably at some point somebody is going to need to change that date. It happens rather frequently with resources. So having it be a date/time embedded TV field isn't really such a bad idea.
        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
        • 42153 ☆ A M B ☆
        • 27 Posts
        You might be right.
        Still, for now i don't want to bother my user with any extra, not relevant info. We promised to show the latest items on the homepage, and that's all there's to it (from the users perspective).

        I probably choose to show it though. I'm spending to much time on the issue already, and have several more to go ;-)
        Thanks again for your replies. I let you know if i come up with something.
          • 4172
          • 5,888 Posts
          you need just create a new field into your formtabs with
          "inputTVtype":"hidden","default":"@EVAL return time();"
          [ed. note: Bruno17 last edited this post 13 years, 8 months ago.]
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            I suspect that if you use the limit property, it will grab the latest x number of entries. It's worth a try, anyway.
              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
              • 42153 ☆ A M B ☆
              • 27 Posts
              Quote from: Bruno17 at Jan 29, 2013, 03:28 AM
              you need just create a new field into your formtabs with
              inputTVtype: hidden
              default Value: @EVAL return time();

              That looks like the solution i'm looking for!
              How do i contruct this in JSON?
              I've got it like this, which doesn't give me errors but also doesn't sort.
               {"field":"date","inputTVtype":"hidden", "default Value":"@EVAL return time();"}
                • 19604 ☆ A M B ☆
                • 179 Posts
                Quote from: jorgenh at Jan 29, 2013, 05:27 AM
                How do i contruct this in JSON?]
                Look at post #14 Bruno17 wrote.
                BTW.: MIGX gets even more awesome the more you work with it.
                  MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
                  http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
                  • 42153 ☆ A M B ☆
                  • 27 Posts
                  @mindeffects And i already think it's awesome!

                  When i use the code of Bruno17, i do have to store it in a variable right? Like field:date. When i do that (like in my code example above), it returns nothing.
                  What am i missing here?

                  The Form tabs as i have them right now:
                  [{"caption":"Kunstwerk", "fields": [
                      {"field":"date","inputTVtype":"hidden","default":"@EVAL return time();"},
                  {"field":"name","caption":"Naam"},
                      {"field":"kind","caption":"Soort","inputTV":"tplSoort"}, 
                      {"field":"size","caption":"Afmeting"}, 
                      {"field":"image","caption":"Afbeelding","inputTVtype":"image"}
                    ]
                  }]
                    • 4172
                    • 5,888 Posts
                    As soon as you save the migx-item the first time you should get a field with name 'date' and the unix-timestamp of the time, when you opened the formtabs-window. This value should not be overriden the next time you are editing this item.

                    I got this in my test:

                    [{"MIGX_id":"2","title":"test2","image":"","description":"","resource_id":"","hiddendate":"1359462335","richtext":""},{"MIGX_id":"1","title":"3","image":"","description":"","resource_id":"2","hiddendate":"1359462345","richtext":""},{"MIGX_id":"3","title":"test","image":"","description":"","resource_id":"","hiddendate":"1359462357","richtext":""}]
                    


                    now getImageList can sort by this field

                    &sort=`[{"sortby":"hiddendate","sortdir":"DESC"}]`
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 42153 ☆ A M B ☆
                      • 27 Posts
                      Thanks Bruno17.

                      We're almost there. Only thing is: the field does get updated every time i call the page. As if the value of field date is 'time();' and not the static unix time on which the item was created.