S
S
Sergey Ignatiev2017-09-13 11:53:52
MODX
Sergey Ignatiev, 2017-09-13 11:53:52

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

3 answer(s)
D
display: block, 2017-09-13
@serebro223

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();
}

You can read more about xPDO:
https://ilyaut.ru/xpdo/

R
Roman, 2017-09-17
@RGBPlus

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)?

V
Vladimir Ratushnyak, 2020-08-03
@ratushnyak

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 question

Ask a Question

731 491 924 answers to any question