We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    This is an auto-generated topic for getValues 1.0.0-beta by opengeek.

    Brief Description:

    getValues 1.0.0-beta (October 12, 2010)

    • Initial release
      • 11139
      • 34 Posts
      Can anyone give me a quick example of what this what be used for?

      I’m trying to get a feel for what can be easily done with the existing MODx resources. Don’t quite understand this one!

      Thanks,

      Thomas
        • 22303 MODX Staff
        • 10,725 Posts
        This simple Snippet allows you to get a single column value from any database object you have generated a class/map for in xPDO. For example, say I have a package called mystuff with a class titled MyClass. This class represents a table with two columns, an id primary key field, and a name field. I can then use getValue to return the name field of a record in the MyClass table (assuming it’s package has been registered in MODX via another Snippet, Plugin, or by registering it in the extension_packages System Setting), e.g.

        [[getValue? &class=`mystuff.MyClass` &field=`name` &where=`{"id":1}` &default=`No value found.`]]
        


        You can also use it with any core MODX classes, e.g. to get the class_key of a specific modResource you might do something like this:
        [[getValue? &class=`modResource` &field=`class_key` &where=`{"alias":"foo", "context_key":"web", "parent":0}` &default=`No value found.`]]