modxcms / fred

The friendly front-end editor for visual, drag-and-drop content building in MODX CMS
https://fred.modx.com
MIT License
57 stars 25 forks source link

could I update the Fred content in MODX resource field with PHP? #486

Closed whatafunc closed 1 year ago

whatafunc commented 1 year ago

Hi there, Fred is good but we have a massive change per the content created with FRED so here is the case:

As far as I know the FRED saves content in resource content field and I have created some php code that should rewrite this field with something like

        $p->setContent($newContent );
        $p->save();

where $p is a page object received from the prior code:

$criteria = [];
$criteria['modResource.content:LIKE'] = '%.webp%';
$criteria = $modx->newQuery('modResource', $criteria);
$pages = $modx->getCollectionGraph('modResource', '', $criteria);
if ($pages) {
    foreach ($pages as $p) {
         .....
         .....
.....
.....

You can notice the code selects any resource where a WEBP image exists and then, after a few modifications it's saving new content, but that content does not get updated neither on the mysql no on the modx level

I think it worked a few times (modx cloud is used) but then it stopped, I do not know maybe it's not allowed to do it that way or there is any specific reason for this, sorry

Can I double check it with you?

PS. MODX cloud advised to escalate this here so please feel free to remove this and PM me directly if it's better

whatafunc commented 1 year ago

UPD: sorry it works on the MODX level but it could be the server issue which is actually just a feature of caching some UI elements