We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18913
    • 654 Posts
    Does anyone have the skeleton of an Evo-to-Revo porting utility they could share? I’ve read the substitutions on Bob’s guides and came up with what is below. The idea is that if Revo were installed alongside an existing Evo site, then one could hit the Evo database directly and output "new" code. This example (not well written or taking advantage of anything built into Revo) is a stab at that for chunks, though the output would still need to have slashes removed.

    Are there other substitutions that I’d need to be aware of?

    Matt

    <?php
    $dbhost = 'localhost';
    $dbuser = 'YOUR_USERNAME';
    $dbpass = 'YOUR_PASSWORD';
    
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
    
    $dbname = 'YOUR_EVO_DATABASE_NAME';
    mysql_select_db($dbname);
    
    $result = mysql_query("SELECT * FROM modx_site_htmlsnippets");  //change this to modx_site_snippets
                                                                    //for snippets
    
    $targets = array(
    "[*",
    "[+",
    "[~",
    "[(",
    "[!",
    "{{",
    "*]",
    "}}",
    "+]",
    "~]",
    ")]",
    "!]");
    
    $substitutions = array(
    "[[*",
    "[[+",
    "[[~",
    "[[++",
    "[[!",
    "[[$",
    "]]",
    "]]",
    "]]",
    "]]",
    "]]",
    "]]");
    
    while($row = mysql_fetch_array($result))
      {
        $text = ($row[snippet]);
        $processed = false;
        echo $row[name] . "<br />";
        foreach($targets as $key => $value)
        {
          $tgtstr = ($value);
          $substr = quotemeta($substitutions[$key]);
          $tgtcnt = substr_count($text, $tgtstr);
          $pos = strpos($text, $tgtstr);
          if ($pos !== false)
          {
            $processed = true;
            echo "  target " . $tgtstr . " found.  Count = $tgtcnt.<br/>";
            for($i=0;$i<=($tgtcnt-1);$i++)
            {
              $text = str_ireplace($tgtstr,$substr,$text);
            }
          }
        }
        if ($processed)
        {
          echo "<pre>" . htmlentities($text) ."</pre><br/>";
        }
        else
        {
          echo "--> No target changes found.<br/>";
        }
      }
    
    mysql_close($conn);
    ?>
    


    EDIT : got rid of the Jurassic-era XMP tag ...

      • 22303 MODX Staff
      • 10,725 Posts
      A tag translation utility already exists that uses the API and can also work on external files. We are putting together an official Evo to Revo migration tool and guide as quickly as possible. In the meantime, check out http://modxcms.com/forums/index.php/topic,42321.0.html
        • 18913
        • 654 Posts
        Great. Yes, not being able to handle external files would be a big gap in the approach I posted. Thanks for the reply and thread link.
        Matt