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

    we have (nearly) finished an importer script to import a huge list of none MODx resources from an old external database (old in-house CMS) into an Articles container.

    The last question to make the import perfect is regarding to the newly added (since MODx 2.2x) field properties of the site_content table:

    As far as I understand, this field normally holds all the settings (properties) form the parent Articles container.

    Is it necessary to fill this field?
    And if so - where do we get the values?
    Does each child resource of an Articles container get the same values in the properties field?

    Thanks,
    Martin

    This question has been answered by multiple community members. See the first response.

      Freelancer @bitego http://www.bitego.com
      ---
      GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
      More infos here: http://www.bitego.com/extras/goodnews/
      • 3749
      • 24,544 Posts
      gadgetto, Splittingred can give you a much better answer, but it looks to me like you can import your articles into MODX as regular resources (either with your script, or the import utility in the Manager) and then use the Articles import utility to pull them into Articles (right-click on the Articles folder in the tree and select "Manage Articles" -- you'll see an Import button).

      I'm guessing that that will set the properties for you. Doing it yourself looks like a pretty serious undertaking.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 3 months ago.]
        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
        • 10378
        • 375 Posts
        Quote from: BobRay at Jun 27, 2012, 11:17 PM
        gadgetto, Splittingred can give you a much better answer, but it looks to me like you can import your articles into MODX as regular resources (either with your script, or the import utility in the Manager) and then use the Articles import utility to pull them into Articles (right-click on the Articles folder in the tree and select "Manage Articles" -- you'll see an Import button).

        Hi Bob,

        thanks for your answer, but we can't do this as the Articles importer doesn't import all fields and especially no TV values (except tags TV). Our Articles resources all have TV values (used for cross posting system).

        So I'm afraid we have to add the properties field contents manually.

        But as far as I understand - each child resource should inherit the content of the properties field from it's container!?
        Could anyone confirm this?

        Greetings,
        Martin
          Freelancer @bitego http://www.bitego.com
          ---
          GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
          More infos here: http://www.bitego.com/extras/goodnews/
          • 3749
          • 24,544 Posts
          You might want to subclass one of the import classes in core/components/articles/model/articles/import and add the TV import.


          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            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
            • 10378
            • 375 Posts
            Quote from: gadgetto at Jun 28, 2012, 04:17 AM

            But as far as I understand - each child resource should inherit the content of the properties field from it's container!?
            Could anyone confirm this?

            Nobody knows this?
            Anyone who worked on the Articles plugin - could you please tell me if this is correct?

              Freelancer @bitego http://www.bitego.com
              ---
              GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
              More infos here: http://www.bitego.com/extras/goodnews/
            • discuss.answer
              • 28215
              • 4,149 Posts
              Yes, that is correct:

              /** @var ArticlesContainer $container */
                      $container = $this->modx->getObject('ArticlesContainer',$this->object->get('parent'));
                      if ($container) {
                          $settings = $container->getProperties('articles');
                          $this->object->setProperties($settings,'articles');
                          $this->object->set('richtext',!isset($settings['articlesRichtext']) || !empty($settings['articlesRichtext']));
                      }
              


              Each new Article gets the properties of the ArticlesContainer (its parent) on first save.
                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                • 10378
                • 375 Posts
                Thanks for your help!
                  Freelancer @bitego http://www.bitego.com
                  ---
                  GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
                  More infos here: http://www.bitego.com/extras/goodnews/
                • discuss.answer
                  • 3749
                  • 24,544 Posts
                  I got this working in NewsPublisher. You have to use $modx->newObject('Article'), set the parent field to the ID of the blog container and set the template field to the id of the blog template. The properties field is then set correctly when you call $modx->runProcessor('resource/create', $fields).



                  ------------------------------------------------------------------------------------------
                  PLEASE, PLEASE specify the version of MODX you are using.
                  MODX info for everyone: http://bobsguides.com/modx.html
                    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
                    • 10378
                    • 375 Posts
                    Quote from: BobRay at Jul 09, 2012, 02:36 AM
                    I got this working in NewsPublisher. You have to use $modx->newObject('Article'), set the parent field to the ID of the blog container and set the template field to the id of the blog template. The properties field is then set correctly when you call $modx->runProcessor('resource/create', $fields).

                    Cool - thanks too!
                      Freelancer @bitego http://www.bitego.com
                      ---
                      GoodNews - one of the most advanced and integrated Group Mailer premium add-ons for MODX Revolution!
                      More infos here: http://www.bitego.com/extras/goodnews/