We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16173
    • 14 Posts
    Hi, all,

    Now Modx supports importing from HTML static pages. That’s good but not perfect. Because the HTML files can’t share any templates/snippets/TVs/chunks with the dynamical pages.

    So let’s imagine if Modx can import from XML.
    The source XML can contain various nodes, each node can be a template name, a TV, etc.
    Then we can put these things in XML, content, template to use, TVs, etc, and Modx inserts each fields to the database same as the user editing in the browser in Modx manager.

    To be brief, the XML is a file form to allow the user to edit a document rather than to edit each fields in Modx manager one by one.

    How can this idea be useful?
    Some web masters may want to use some tool to grab information from another database and then publish them on a Modx site. Allowing XML import will automate the whole work and much more productive.
    For myself, I need to use a Perl scrit I wrote to generate many pages and publish them on my site.
    It will be annoying to edit documents one by one.

      • 25663 MODX Staff
      • 12,272 Posts
      Actually you could probably copy the base found in /manager/actions/import_site_static.php file and turn it into a module to enable importing from XML files, with whatever logic you need for your application.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 16173
        • 14 Posts
        Quote from: rthrash at Oct 18, 2007, 11:21 AM

        Actually you could probably copy the base found in /manager/actions/import_site_static.php file and turn it into a module to enable importing from XML files, with whatever logic you need for your application.
        But I think this idea is so useful that Modx should include it in the core release.
        Not every one are like to modify the original code.
        And even worst, somebody like me, almost doesn’t know PHP.
        laugh
          • 22303 MODX Staff
          • 10,725 Posts
          I don’t see how this would be that useful; is there some kind of XML schema or other standard for the content format you are proposing, or are you proposing a proprietary format be created for this? I see importing the contents of the body tag or an entire document from HTML as much more useful since it is a widely accepted content formatting standard, whereas making up an XML format just for this purpose might be useful to one or two users that have created a way (likely via XSL) to easily author or convert content into this less accepted format.
            • 16173
            • 14 Posts
            OpenGeek,

            Then how does the user generate the HTML? Use which template?
            I think it’s hard to use Modx template outside of Modx (e. g, I don’t know how to reuse Modx template in my Perl script).
            If we use XML, we can specify,
            1, which template to use,
            2, what the content is. I can set a bunch of text in a XML node to present the content.
            3, the TVs value I want to set.

            I think for anyone want to automate the page generation, XML is much more useful and powerful than HTML.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              I can see that you have a use for an XML import feature, but I also fail to see where it would be something the average user would ever use. This is a candidate for a third-party module, not for a core modification. No software ever suits everybody, and it can’t because everybody will have something different that they want to do. MODx is attempting to make third-party customizations as easy as possible, through snippets, plugins and modules. The core needs to remain as clean and simple as possible to avoid forcing everyone to carry the bloat of features they will never use.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 16173
                • 14 Posts
                sottwell,

                I agree with you.
                A plugin for this feature is also great too.
                To be honest, I don’t think it’s hard to write a plugin for such a feature as we alread have a importing HTML there. But it’s a pity I don’t know PHP so I can’t do it by myself.
                tongue
                  • 26085
                  • 494 Posts
                  Quote from: KomsBomb at Oct 20, 2007, 01:09 AM

                  sottwell,

                  I agree with you.
                  A plugin for this feature is also great too.
                  To be honest, I don’t think it’s hard to write a plugin for such a feature as we alread have a importing HTML there. But it’s a pity I don’t know PHP so I can’t do it by myself.
                  tongue

                  Now you can use import from csv files (look at links below).
                  If do you really need import from XML let me know, because I am going to write samething like this. I have wrote a php class and I just need to integreate it to modx.

                  ps. sorry for english smiley
                    • 16173
                    • 14 Posts
                    Hi, SamZ,

                    Thank you for the link.

                    Suggestion on the CSV version:
                    1, You should include a detailed help file in HTML to show how to use it.
                    2, The content in the sample CSV is in Russian? No, you should make it in English.

                    But I still think a XML version is better. XML is more easy to use than CSV and it’s the main stream nowadays.

                    If you would like to write a XML version, here is my wish list,
                    1, You module only picks up one index file. The index file is a XML too. It tells the module which XML files should be imported.
                    For example,
                    <ThisIsIndex>
                    <FirstOne type="document" file="doc1.xml" />
                    <SecondOne type="weblink" file="weblink1.xml" />
                    </ThisIsIndex>

                    Of course such a index file is not a must. You can enumerate a folder for all xml files as input.

                    2, In each document XML file, I wish it can contain each fields in the Modx web form as nodes. That’s to say, maybe one node is for content, one node is for template, one node is for title, some nodes are for TVs, etc.

                    I will much appreciate you if you consider my advice.
                    grin grin grin