Hi, i have a TV 'categorie' it's a list box and has a default value of @INHERIT.
All works fine. All children of the parent folder that have the categorie set to 'something' all seem to have that value set. When i call a resource and get its TV 'categorie' 'something' will show up fine.
BUT whe checking the 'tmplvar_contentvalues' table i see that these TVvalues are actualy not set to the resource. MODX finds it through the parent at runtime (realy smart i admit). But when i do a getCollection including the TV where value == 'something' not all resources will show up because some of m rely on the INHERIT and do'nt have a value in the database.
I Think i understand how and why this works, but i don't want that.
I want the TV value to be set on creation of the resource and then be saved as well. How can i enforce this?
without having my client to actualy select the TVvalue?
tnx
Rdg
-
☆ A M B ☆
- 24,524 Posts
I think getResources will filter by TV value and will respect @INHERIT bindings. You could look at the getResources code to see how it sets up the query for getCollection().
It's complicated. TVs are not really built for searching, but rather as a way of shoehorning extra fields into a resource. Since TVs are not actual Resource fields, they exist in several different tables and the value of the an @INHERIT TV is, as you say, calculated on the fly.
One way to go would to loop through the Resources using $resource->getTVValue(), which will give you the same results you'd get with a tag.
It's possible that a query on the modTemplateVarResource object, which holds the values for each resource, would calculate the values of @INHERIT TVs. I've never tried it.
http://bobsguides.com/modx-object-quick-reference.html#modTemplateVarResource.
- tmplvarid (integer) -- ID of the TV
- contentid (integer) -- ID of the Resource
- value (string) -- Value of the TV for that Resource