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

    I'm trying to move an old web site to MODX. I managed to import html file, but I get only datas in content, alias and title. I would like to know if there is a way to set the Publish Date.

    For example I have this file :

    <html>
      <head>
        <title>My Title</title>
      </head>
      <body>
        <div id='pub_date'>2010-03-10</div>
        <div id='content'>
          <p>The content</p>
        </div>
      </body>
    </html>
    


    I would like to have <title> in title and long title, <div id='pub_date'> tag content in the publish date, and finally <div id='content'> tag in content.

    Regards

    Julien

    This question has been answered by JuTs. See the first response.

      • 3749
      • 24,544 Posts
      I think you'd have to rewrite the code that imports the files. Do you know where it is?
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
      • discuss.answer
        • 15114
        • 102 Posts
        Yes, I found it : model/modx/import/modimport.class.php

        And I also found a solution to import my data without modification.
        I changed the structure of the files I want to import with:

        <html>
          <head>
            <title>My Title</title>
          </head>
          <body>
            <date>2010-03-10</date>
            <content>
              <p>The content</p>
            </content>
          </body>
        </html>
        


        and in the "Enter the root HTML element to import:" field I put

        {"content":"$content","pub_date":"$date","published":"1","longtitle":"$title"}


        In french translation the help text is a bit misleading.

        In english it says "Provide JSON with associations "field":"value". If value starts with $ it is jQuery-like selector. Field can be a Resource field or TV name."

        In french : "Fournit un ensemble JSON avec des associations « champ »:« valeur ». Si la valeur commence par $ c'est un sélecteur de type jQuery. Le champ peut être une ressource ou le nom d'une TV."

        If I translate the last part of the french text that would be : "Field can be a Resource or TV name" (without the "field" word). I think the french translation should be : "Le champ peut être un champ de ressource ou le nom d'une TV."

        [ed. note: JuTs last edited this post 10 years, 4 months ago.]
          • 3749
          • 24,544 Posts
          That's a beautiful solution. I didn't know that import was that flexible.

          Do you mind if I use your solution for a blog post?

          If you don't mind, you could also suggest your change here:
          https://github.com/modxcms/revolution/issues
          . You can actually make your change to the lexicon file at GitHub and generate a pull request.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 15114
            • 102 Posts
            Quote from: BobRay at May 30, 2016, 01:14 AM

            Do you mind if I use your solution for a blog post?

            That's a good idea, this could be useful to others people.