Hi,
I'm trying to import a bunch of HTML files using the import html tool built into MODX. My issue is I need to import the files from the top down and not based on a selector. Many of my files are starting with <style> or <script> or other variants. I've tried leaving the element selector blank and a few other methods to no avail.
Any ideas?
Thanks,
You could try the ImportX extra, but I'm not sure it would be any better.
A custom snippet could work, but I'm not clear on what you want to do, which resource fields you want to capture, what you want for a pagetitle, how many files there are, etc.
Thanks for the reply bob. There are roughly 1000 pages which rules out importx happy to use file names for titles no fields just content
discuss.answer
I managed to import all files from the top down without a selector by using:
I'm glad you got it sorted. Thanks for reporting back.
I'll try to remember to do a blog post on this.
LK, I finally got around to working on a blog post for this, but found I didn't understand your use case.
Using your selector with a file with html, head, and body tags, I still get only the content of the body section.
If the script and style tags are in the body section and I use the default {"content":"$body"}. They come through fine.
I guess I need some more details.
Hey Bob,
Sorry I've only just saw your reply on this.
In this particular case the .htm files I was trying to import didn't contain a head or body element and came from an adaptive ecommerce site. As such many of the .htm files started with a script tag that handled redirection between the mobile or desktop version of the site, some started with a <style> tag.
The above selector on the import tool did work for me though and I've just checked one of the files and there was no empty line present at the top either.
OK, got it. Thanks!
FYI, in my tests, MODX set the richtext field no matter what, so if TinyMCE was installed and enabled, it removed the script and style tags when it loaded the resource content for the first time.
Yeah I did run into that also
Disabling rich text by default is a necessary step I think!
Turning off richtext_default had no effect for me.