Resource ID Question

We have a site that we built for a client. On certain pages we had a link to another document (not in the navigation - not published) called Privacy Policy. The resource ID was 22.

For some reason, the client deleted the page, of course all the hard links pointing to Resource ID 22 failed. We fixed it by recreating the page and changing the link to point to the new resource id of 34.


How can we prevent this in the future (we are going to implement ACL), or did we not do something right to make MODx realize that the resource ID has changed or is there some way of using dynamic links to resource IDs?

I hope this is clear, if not I can expand.

Welcome to MODX. Your question is very clear.

There’s no way to make MODX magically realize that a link should suddenly point to a different page, but there are ways to mitigate and/or prevent the damage.

First of all, you can use the security system to make sure that certain people can’t delete important pages. If you had put resource 22 into a Resource Group, and connected that Resource Group to the Administrator User Group with a Resource Group Access ACL entry, no one outside of the Administrator group could see, edit, or delete that resource. (And, imo, membership in the Administrator group should be reserved for high-level administrators).

Another, not so secure, method would be to create a TV or a System Setting that stores the ID of the page (22). I would use a System Setting called privacy_page with a value of 22. Then, when you need a link to it you’d do something like this:

<p>Please read our <a href="[[~[[++privacy_page]] ]]">Privacy Policy</a>

That’s a System Setting tag ([[++setting_name]]) inside a link tag ([[~22]]).

When MODX processes the tag, [[++privacy_page]] will be replaced by the value of that setting (e.g., 22). Leaving the tag looking like this:


The link tag, [[~22]], will be replaced by the URL of page 22.

Now, when the page changes, you just need to change the value of the privacy_page System Setting.

Are you using the VersionX plugin? If not, you should. That keeps copies of all edits done to all your resources, so you can easily revert to a previous version of any page. And, if someone deletes a page, and then also purges it using the Trash manager, you can STILL get it back by going into the VersionX plugin, finding the most recent version there, and restoring it. I’ve used the plugin to save my clients several times in recent years after someone accidentally deletes and purges a page!