Answer the question
In order to leave comments, you need to log in
How to make a single TV field for multiple resources in MODX?
You have to periodically change the content of the TV in a large number of resources. TV content is the same in all resources. But their content is different. It is very inconvenient to open each resource and manually change TV in it.
How to change the content of the TV 1 time and it has changed in many resources with different content?
Answer the question
In order to leave comments, you need to log in
Through the Console plugin, we access Modx via xPDO
<?php
$tvName = 'sale';
$tvValue = '40';
foreach($modx->getCollection('modResource') as $res){
$res->setTVValue($tvName, $tvValue);
$res->save();
}
If the data in TV is the same everywhere, then why use TV at all, if it can be written in a template (mono with a condition for each category, for example)?
Specify the &docid parameter (you can specify the ID of the document whose TV should be processed. Default: 2).
For example,
You can make the TV field available only for one template and fill it on only one page (resource), and use the field itself via a chunk with other templates and pages.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question