I’d like to create lists of things that I can edit use easily. I really like the way the TVs work, but you can only have one of those, not an array.
What I’m thinking is, lets say I want to create a simple gallery, I could have a list with my predefined fields that I could call from the content or template or whatever. I know there is already a gallery, but I’d like it if there was an easy way to create a module, where I can create a table with fields, it would make development of snippets so much easier, because I wouldn’t have to worry about dealing with the database within the snippet, but just a simple abstraction.
Is there something like this that exists already and I don’t know about it?
Seems like this could be really handy in creating lots of stuff.
-
☆ A M B ☆
- 24,524 Posts
Why can’t you have an array in a TV? Use @SELECT or even @DIRECTORY as its default value, then use a snippet to output your TV’s content; in the case of the mini-gallery, if using @DIRECTORY to automate the gallery, explode() the TV’s content, loop through the resulting array and generate the appropriate HTML tags for each item. @SELECT produces an ordinary MySQL SELECT resource like any SELECT query.
You can also manually generate your list of images in a chunk, and use the chunk as the input for the TV with @CHUNK, again using a snippet to process the TV’s output.
You can even hide these TVs from document editors so they can’t accidentally break them, simply by creating a document group and assigning the TV to that group. Only Administrator manager user can then see the TV.
http://www.sottwell.com/tv-bindings.html
http://wiki.modxcms.com/index.php/Adding_TV_Widgets_without_hacking_the_core
Regarding the array, I meant that it would be handy to have an array of template variable, not an array within the template.
But in reality that probably wouldn’t help much, however if there was a group of TVs (like file, image and two textfields) and those were in an array or a table that’s what I’m looking for.
I’m sure this kind of functionality would need a separate database table. And that’s the thing I would like to make easier, is the editing of the database through TVs(or something similar to that).
Getting the data out of the db could then be done through the @SELECT.
Basically it’s the editing of the database that I would like to make easier for a non developer that’s using the site. As far as I know there’s no way of scaffolding a table, but then I’m still learning modx.
What about this?
adding TVs to a page (and maybe removing some of the usual fields like content)
and then adding a bunch of pages as a child of another page.
then that parent could do whatever logic is necessary to display news, blogs, image galleries, product display, etc.
Maybe this would be a way of circumventing this table structure I was thinking about.
But I think that a lot of CMS users across a lot of CMSes rely on creating tables of information that need to have a database, so rather than hacking the pages to hold data, I’d like to see something like a Tables structure that would be accessible like chunks snippets and TVs are