Collections

Imorting HTML Documents Into Collections Containers

light fare

Importing to Collections

If you want to import a bunch of HTML documents using the Import HTML function, importing them into Collections containers doesn't hide them in the Tree. This trick came up in a Slack conversation.

sottwell asked...

The Import HTML function won’t set the imported resources to not show in the Tree, so you’d need to save every one individually in the Collection to get them set right, or else spend a lot of time in the database. Is there an easier way?

The Solution:

sottwell says...

The trick is, don’t create a Collection. Create a normal resource in the Tree to use as the parent container, import the HTML documents, then change the container resource to a Collection. That will automatically reset all of its children to not show in the tree.

So what to do if you already have several Collections with hundreds of imported HTML docs each? Use Quick Update on the Collection folder, convert it to a normal Document, save, then convert it to a Collection, save again and close the QuickUpdate dialog.

What's the Story?

The Import function only deals with what parent resource to assign the imported HTML resources. So if you've imported into Collections containers, all of the resources are still in the Tree. Setting a container to a Collection Resource Type in its Settings tab will update all of its children to not show in the Tree. So if you already have a Collection container with a bunch of resources that were imported, simply change it back to a Document Resource Type, save it, then change it to a Collection again, and let MODX update all of its children. Now everything is nice and tidy, with everybody where they are supposed to be.