We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1041
    • 51 Posts
    Discuss works quite fine for me, so I can not wait to replace forum software to Discuss on one of my projects. So I tried to convert my recent SMF-based forum to Discuss (on localhost). There is no manual, so I had to guess about everything smiley

    I've found \core\components\discuss\includes\import.smf.php. Ok, lets look into it..

    First I have to rename import.config.inc.sample.php to import.config.inc.php and edit it:
    $config['smf']['dsn'] = 'mysql:dbname=smf;host=localhost';
    $config['smf']['username'] = 'root';
    $config['smf']['password'] = '';
    $config['smf']['tablePrefix'] = 'smf_';
    
    $config['live'] = true;
    $config['import_users'] = true;
    $config['import_categories'] = true;
    $config['import_private_messages'] = true;
    $config['import_ignore_boards'] = true;
    
    $config['default_user_group'] = 'Forum Members';
    $config['usergroup_prefix'] = 'Forum ';
    $config['attachments_path'] = false;


    Also I have to edit import.smf.php
    $modx->resource = $modx->getObject('modResource',236);

    where "236" is my discuss.forums_resource_id

    Seems, that's all. Am I right?

    I'm accessing to converter via browser http://mysite.ru/core/components/discuss/includes/import.smf.php and it gives me:
    [2013-03-07 18:58:04] (WARN @ /core/components/discuss/includes/import.smf.php) `236` was requested but no alias was located.
     [2013-03-07 18:58:06] (INFO @ /core/components/discuss/includes/import.smf.php) Starting import...
    [2013-03-07 18:58:06] (INFO @ /core/components/discuss/includes/import.smf.php) Encoding conversion set to: UTF-8 => UTF-8
    [2013-03-07 18:58:06] (INFO @ /core/components/discuss/includes/import.smf.php) Migrating Ignore Boards...
    [2013-03-07 18:58:06] (INFO @ /core/components/discuss/includes/import.smf.php) Collecting User cache...
    [2013-03-07 18:58:06] (INFO @ /core/components/discuss/includes/import.smf.php) 
    Execution time: 2,5631 s
    

    and I look into DB - nothing was converted to Discuss sad

    What did I do wrong?

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

      • 1041
      • 51 Posts
      I'm trying to explore \core\components\discuss\model\discuss\import\dissmfimport.class.php by inserting this to different lines:
      $this->log('_mylog: something');


      As a result I found the right place:
          public function importUserGroups() {
              $stmt = $this->pdo->query('
                  SELECT * FROM '.$this->getFullTableName('membergroups').'
                  ORDER BY `groupName` ASC
              '.(!$this->config['live'] ? 'LIMIT 10' : ''));
      				
              //if (!$stmt) { return 'Failed importUserGroups.'; }
              if (!$stmt) $this->log('_mylog: failed importUserGroups()');
      
              while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
      
      ... 

      It gives me my message to log.

      I'm not so strong in pdo.. What does (!$stmt) mean?

      Also I tried to replace:
          public function importUserGroups() {
      //        $stmt = $this->pdo->query('
      //            SELECT * FROM '.$this->getFullTableName('membergroups').'
      //            ORDER BY `groupName` ASC
      //        '.(!$this->config['live'] ? 'LIMIT 10' : ''));
      		$sql = 'SELECT * FROM '.$this->getFullTableName('membergroups').'ORDER BY `groupName` ASC'.(!$this->config['live'] ? 'LIMIT 10' : '');
      		$q = $modx->prepare($sql);
      		$q->execute();
      
      //      while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
              while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
      ...
      

      It gives me:
      Fatal error: Call to a member function prepare() on a non-object in ...

      • discuss.answer
        • 1041
        • 51 Posts
        As usual, I found the answer by myself)) I looked at the code and saw DB table and row names not like in my SMF installation, so the ansver is:

        SMF must be 1.x.x! Discuss converter does not work with SMF 2.x.x!

        I made downgrade from my 2.0.4 SMF to 1.1.12 and configured converter as I described in 1st post. Seems, that everythimg works fine now.
        • Mark Hamstra Reply #4, 11 years ago
          Thanks for sharing your solution. I've not tried the SMF import myself and taking into account when it was written, I'm not surprised it doesn't work with the latest version. laugh

          Could you write a tutorial / documentation piece to help people with the import? If you don't have access to edit the RTFM, shoot hello at modx.com a message or let me know what to put in where.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 1041
            • 51 Posts
            Thanks for your invitation smiley I could write some scratch tutorial, but wouldn't it be better to ask the author of converter scripts? There is a lot of things I do not understand therein. Almost everything I understood I wrote in first post on this page.

            Also I must tell that once I figured out how to convert, I left this venture smiley For some reasons I decided to give my new forum a fresh start, and asked old forum moderators to move some valuable messages to new forum manually smiley