Cannot change template for resource

I am trying to change the template in a resource, click save and the save dialogue never completes?
This is modx3 installed in xampp local test server. I have tried clearing the cache, logging out sessions and deleting the cache file.

Open the developer tools in the browser and go to the “Network” tab. Then try to save the resource. It should create a new AJAX-request that probably fails. Is there some error message in the response of this request?

Also, check the MODX error log to see if something gets added, when you try to save the resource.

Nothing I can see, but I have this in the console
This page uses the non standard property “zoom”. Consider using calc() in the relevant property values, or using “transform” along with “transform-origin: 0 0”. manager
Some cookies are misusing the recommended “SameSite“ attribute 10
window.controllers/Controllers is deprecated. Do not use it for UA detection. ace.min.js:1:18511
Error in parsing value for ‘width’. Declaration dropped. manager
Error in parsing value for ‘width’. Declaration dropped. 6 manager
The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it. index.php
Uncaught SyntaxError: expected expression, got ‘<’
ExtJS 2
handleResponse http://localhost/modx3/manager/assets/modext/modx.jsgrps-min.js?mv=303pl:19
ExtJS 5
ext-all.js:1:1

When you click the save button for a resource in the manager, it generates a request (with the parameter “action” = Resource/Update and all the resource data).

A successful request has a JSON response that looks something like this:

{
	"success":true,
	"message":"",
	"total":0,
	"data":[],
	"object":{"id":9,"type":"document",...}
}

So what is the response in your case?

I get this in request tab
{
“start”: “0”,
“limit”: “20”,
“action”: “Element/Template/GetList”,
“combo”: “true”,
“query”: “”,
“HTTP_MODAUTH”: “modx645be0ba8a8847.80639986_164aef272503c82.59073782”
}

Is this what you mean

{
“success”: true,
“total”: 4,
“results”: [
{
“id”: 0,
“templatename”: “(empty)”,
“description”: “”,
“category_name”: “”,
“time”: 1689319295
},
{
“id”: 2,
“templatename”: “blog”,
“description”: “”,
“category_name”: null,
“preview”: “”,
“time”: 1689319295
},
{
“id”: 4,
“templatename”: “blogList”,
“description”: “blog template”,
“category_name”: null,
“preview”: “”,
“time”: 1689319295
},
{
“id”: 3,
“templatename”: “contact”,
“description”: “”,
“category_name”: null,
“preview”: “”,
“time”: 1689319295
},
{
“id”: 1,
“templatename”: “home”,
“description”: “”,
“category_name”: null,
“preview”: “”,
“time”: 1689319295
}
]
}

No, that’s the wrong request.

The “action” parameter should be “Resource/Update” (which updates a resource), not “Element/Template/GetList” (which loads all the available templates).


Open the “Network” tab in the developer tools first, then click the “Save” button. The first request that gets added should be the correct one.

This is all I get, I click the dropdown for template, click ok in the dialogue, then it tries to save.
{
“start”: “0”,
“limit”: “20”,
“action”: “Element/Template/GetList”,
“combo”: “true”,
“query”: “”,
“HTTP_MODAUTH”: “modx645be0ba8a8847.80639986_164aef272503c82.59073782”
}

When I just click the save button, I get this response

-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“pagetitle”

blog posts
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“alias”

blog-posts
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“longtitle”

-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“description”

-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“introtext”

-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“ta”

-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“published”

1
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“deleted”

0
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“publishedon”

2023-07-12 21:18:00
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“pub_date”

-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“unpub_date”

-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“template”

2
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“hidemenu”

0
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“menutitle”

-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“link_attributes”

-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“menuindex”

3
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“id”

4
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“type”

document
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“context_key”

web
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“content”

-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“create-resource-token”

64b181256e18a6.47652231
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“reloaded”

0
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“parent”

0
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“parent-original”

0
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“class_key”

MODX\Revolution\modDocument
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“content_type”

1
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“isfolder”

1
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“show_in_tree”

1
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“hide_children_in_tree”

0
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“alias_visible”

1
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“uri_override”

0
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“uri”

-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“parent-cmb”

-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“content_dispo”

0
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“richtext”

0
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“searchable”

1
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“cacheable”

0
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“syncsite”

1
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“action”

Resource/Update
-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“resource_groups”


-----------------------------320001330615658211003514193393
Content-Disposition: form-data; name=“HTTP_MODAUTH”

modx645be0ba8a8847.80639986_164aef272503c82.59073782
-----------------------------320001330615658211003514193393–
I found this

{
“sortBy”: “menuindex”,
“currentResource”: “4”,
“currentAction”: “resource/update”,
“action”: “Resource/GetNodes”,
“node”: “web_8”,
“HTTP_MODAUTH”: “modx645be0ba8a8847.80639986_164aef272503c82.59073782”
}

Ok, so this is the correct request. But what is the response of this request?

1 Like

This problem happens only when trying to save resources, I just clicked save without changing anything.

{
“success”: true,
“message”: “”,
“total”: 0,
“data”: ,
“object”: {
“id”: 4,
“type”: “document”,
“alias”: “blog-posts”,
“published”: true,
“pub_date”: 0,
“unpub_date”: 0,
“parent”: 0,
“isfolder”: true,
“richtext”: false,
“template”: 2,
“menuindex”: 3,
“searchable”: true,
“cacheable”: false,
“createdby”: 1,
“createdon”: “2023-05-11 20:21:53”,
“editedby”: 1,
“editedon”: “2023-07-15 10:13:08”,
“deleted”: false,
“deletedon”: 0,
“deletedby”: 0,
“publishedon”: “2023-07-12 21:18:00”,
“publishedby”: 1,
“donthit”: false,
“privateweb”: false,
“privatemgr”: false,
“content_dispo”: 0,
“hidemenu”: false,
“class_key”: “MODX\Revolution\modDocument”,
“context_key”: “web”,
“content_type”: 1,
“uri”: “”,
“uri_override”: 0,
“hide_children_in_tree”: 0,
“show_in_tree”: 1,
“alias_visible”: true,
“create-resource-token”: “64b254fbe5ecd1.28699080”,
“reloaded”: “0”,
“parent-original”: “0”,
“parent-cmb”: “”,
“syncsite”: 1,
“action”: “Resource/Update”,
“preview_url”: “http://localhost/modx3/index.php?id=4
}
}

So when you click save without changing anything, does it save successfully (or does the save dialogue also never complete)?

What is the response from the “Save” request in the case when the save dialogue never completes?

Save dialogue never completes

As a test, temporarily deactivate all the plugins that run on the events “OnDocFormSave” and “OnBeforeDocFormSave”.

  • The plugins have a toggle switch “Deactivate Plugin” to deactivate them.
  • The manager page for the system settings (manager/?a=system/settings) has a tab “System Events”, where you can see what plugins run on which events. Use the search field to filter by the event.

Also maybe check the PHP error log of the server (that’s not the log file from MODX), to see if something gets logged there.

Deactivated all plugins, cleared cache. Do not seem to have a php error log in xampp control panel

There should be a setting “error_log” in the server configuration (php.ini) that specifies the path of the error log file.

Maybe also check the settings “log_errors”, “error_reporting” (and possibly “display_errors”) to make sure an error gets logged (or shown on screen).

This file and folder does not exist?
error_log=“C:\xampp\php\logs\php_error_log”
enabled other settings

I have the Extra Seo Suite installed, which ‘abuses’ the longtitle field and since then the saving dialog never closes when there are html-elements like <strong> in the longtitle field. After refreshing the page to get rid of the dialog, saving has completed anyway.

@esger When I test it, I get the error “unterminated regular expression literal” in the console of the developer tools. Somehow the code seems to create an error when there is a HTML tag in the JSON response of the update request.


On MODX 3, you could add the line

unset($resource->_fields['seosuite_description']);

after this line in the code

and check if that fixes the issue.

1 Like

Sure going to try that as it’s very annoying :slight_smile: Won’t this extra line cripple some functionality of Seo Suite, as the longtitle field is used by it to fill meta description tags?

I don’t think so. But I haven’t much looked into it.

1 Like