Hello,
in my project there are several different fields in several tables which don’t belong to the base set of tables created by ModX.
I’d like to know...
1. ... how to display a single or multiple or all values from a single row which is related to the user who’s currently logged in (WHERE user_id = something), how to insert the user ID of the current user into the query and how I can make these values editable by the user.
2. ... how to display all rows from a table in a grid or something (okay, this one has to be easy).
3. ... where I can find a really detailed "in-depth tutorial" regarding TVs.
I couldn’t find any documentation or examples on how to use the different settings available for creating a new TV.
Any kind of help would be greatly appreciated.
Thanks a lot!
Hendrik
-
MODX Staff
- 730 Posts
2. ... how to display all rows from a table in a grid or something (okay, this one has to be easy).
I had actually never done this but also knew it was supposed to be simple. So I tried it out and indeed, it was easy. Here’s how I did my proof-of-concept:
- created a simple little db table called test_data with columns id, name, description and added 3 rows of test data to it
- created new template variable called test-grid, with following properties:
* Input Type: text
* Default Value: @SELECT name, description FROM test_data
* Widget: Data Grid
* Data Grid Column Names: Name,Description
* Data Grid Field Names: name,description (looks like they have to match your SQL)
* other Data Grid parameters as per: http://www.modxcms.com/datagrid-widget.html
- make sure that the template variable is assigned to the template where you want to use it
- in a MODx document, using the template that has the TV assigned to it, call the template variable into the content area like this: [*test-grid*]