Articles to Collections

I’ve got a site in MODX 2 that I need to rebuild in MODX 3. I’m choosing to rebuild as this site was originally built in EVO and I’ve upgraded it over the years and there are too many unused chunks and TVs to sift through.

If I create a clean installation of MODX 3 and set up a collection to handle the blog posts that were in Articles how do I import just those Articles from the database? I’m guessing I will have to change the document type and parent for each but wondering if there’s an efficient way to do that.

1 Like

Yes, the column class_key has to be the default MODX\Revolution\modDocument instead of Articles\Model\Article (or Article).

One way would be to execute an SQL query that makes the changes for all resources. Something like

UPDATE `modx_site_content`
SET `class_key` = 'MODX\\Revolution\\modDocument', parent = 99
WHERE `class_key` = 'Article';

Thank you Harry. How would I just export the Articles from the original site, and nothing else?

I dont’ know what the best option is here. These kinds of tasks can get quite tricky, as the data in the resources table has connections to other tables.

For example fields like “createdby” or “editedby” point to a user in the users table. Does this data have to be preserved? Do you also migrate the users?

The same is true for the TV values (for example for the tags) that are stored in a different table. Do you want to export the TV values as well? Do the same TVs exist on the new installation with the same IDs?

Do the same templates exist on the new installation with the same IDs?

You make some very good points there Harry. I don’t think I’m going to be able to completely automate this by the looks of it. I might be better to take a copy of the site and then strip it right back to just the Articles content and then switch that content to Collections and then upgrade to MODX 3. I’m just aware that ‘getting rid’ of the Articles extra at that point, might get sticky.

I know that at one time Articles and Quip were very difficult to remove completely. I recall having to search for left-over bits in the DB. That was quite a while ago, and I don’t know if it’s still true.

I think it’s pretty much still the case.

You might take a look at the Orphans extra. It can help you identify unused objects, though you need to use it carefully.

Thank you Bob - I tried it for the last round of updates on this site but just wasn’t confident about using it. I’ve reached that point where a complete rebuild is going to be less hassle than upgrading again - I’m pretty sure of that. It was built in 2010 originally.

What I’ve done for content audits and similar is to use a getResources call to output all the fields I want into a CSV format where the tpl is the row with all the fields I need to migrate, including the resouce fields, to the createdby/editedby, and attached TVs.

It takes a bit of time to set up but it’s a simple way to not have to write the mysql query to do the same thing. Then you can use ImportX to map and import to your clean install.

I did this on the same site in 2021 when amalgamating it with another site but you have given me food for thought there.

1 Like

Orphans makes me nervous too. I often just rename the orphans and surf the site watching for missing stuff, then check the error log to see if anything shows up there.

1 Like

chrisandy, just saw this topic in the Community email and I am all ears. I am in a similar boat and was going to try to do the same thing in the future. But I don’t have a ton to move. (I also have another large project but that is eventually moving from Expression Engine to MODX with hundreds/thousands of articles and is another whole kettle of fish.)

But my largest issue with this smaller endeavour, thus far, is getting Collections working as a blog, for filing articles etc… Thought I would start with getting the basics working first and that was as far as I made it. I never thought it would be that hard to setup a clean install with a blog in MODX 3, ready to file blog articles into.

If you can get Collections setup and working instead of Articles, I (and probably many others) would like to know how you did it because I gave up trying to get a blog or anything like it working in MODX 3 using Collections instead of Articles.

There is no actual step by step directions that actually work for MODX 3 and Collections.

I was trying to use: Create a Blog in MODX Revolution
And found this in trying to move the basic idea, without all the bells and whistles, to MODX 3 (it was a long road to find this link): Adachi Web -Setting up blog pages with MODX 3
But I was not successful. I guess if a person is a MODX expert it might seem easy to follow the second link directions but I am not an expert and ran into issues I couldn’t figure out, since the directions are not clear. I put it on the shelf until things matured more and I now see this post!

Have you actually tried to set up Collections in MODX 3 for posting articles or a blog and it actually worked?

@macheritage what pat did you get stuck on.

Without writing a whole blog post or series(right now), at it’s simplest, a blog using Collections is typically comprised of a handful of Extras:

  • Collections
  • getPage
  • getResources
  • Tagger (optional)

Here is the basic structure and steps:

  • You’ll make your blog parent a Collection.
  • The default config for a Collections view is a blog, so that’s handled.
  • Then you can add your getPage/getResources call to the document or it’s template.
  • Then you can create the sub-views (this is the part that is handled automagically by Articles). These will be the chunks for the list items.
  • Then you’ll customize a template for the individual post view.

If there’s any specific part of this that you’re unsure about, ask away. We’ll gladly help.

Here’s a short video overview. This isn’t a full step-by-step tutorial, however, it does outline the key points mentioned above.

1 Like

Oh my, thank you Jay!

There was something in trying to get the first link directions working in MODX 3 with the second link directions that I ran into issues. There was something he didn’t properly explain in that second link. Can’t remember the exact part, since I spent some time trying to make it work. MODX 3.0.5, I think, had just come out or around there, so there were still bugs and major fixes happening.

When I have a little time, I will restart with your video and basic instructions and see if I run into any problems I can’t figure out, this time around, and report back.

1 Like

Is anyone using the MODX 3 version of Articles? Is it fully functional yet?

I’m using it on one site that I upgraded from MODX 2. Functioning fine but planning on converting to Collections in the next upgrade / rebuild of the site. It just feels a bit wrong to be using it - to enmeshed in dependencies in my view.

Thanks for the info. Are you using Quip or Archivist on that site?

Quip has never been adapted to MODX 3 (and was removed as a dependency of Articles). Archivist should still work on MODX 3 (and gets installed with Articles).