We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29522
    • 10 Posts
    Hi all,
    how do i transform an existing php driven website to MODx??

    for example, i have a header-file with a lot of functions, like:

    
    ## Database constants 
    
    define('DBHOST','xxx'); // host, usually localhost
    define('DBUSER','xxx'); // name of databse user
    define('DBPWD','xxx'); // password for database
    define('DBDB','xxx'); // name of your database
    
    ## database connectie
    
    function conn()
    {
    	$conn = mysql_connect(DBHOST, DBUSER, DBPWD);
    	if (!$conn)
    		return false;
    	if (!mysql_select_db(DB))
    		return false;
    
    	return $conn;
    }
    
    ## POST
    
    function isPost()
    {
    	return $_SERVER['REQUEST_METHOD'] == "POST"; //geeft true of false
    }
    
    ## Sanitize MySQL Data
    
    function sanitize($data)  
    {  
    	$data = trim($data);  // verwijder spaties aan begin en einde van $data   
    	if(get_magic_quotes_gpc())  
    	{  
    		$data = stripslashes($data); // Verwijder slashes indien magic_quotes_gpc aan staan    
    	}
    	$data = mysql_real_escape_string($data); // MySQL verbinding nodig voor gebruik van deze functie!  
    
    	return $data;  
    } 
    


    And a lot more of course.

    But for example, how do i proces all other php tasks, like processing forms??

    As far as i see, do i need to cut my whole script in pieces and make snippets of it??
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      You don’t have to cut it all in pieces. Its definitely much easier to maintain afterwards though.


      If the data you are quering for is in the same database as the MODX database, you will not need to make the connection manually or sanitize data if you use xPDO objects to query stuff.


      I personally find it easiest to use existing Extras to perform tasks like processing forms (FormIt) or keep track of comments (Quip). There’s quite a number of good extras in the repository and a lot in the works - and the community is more than happy to help you achieve your goals.



      As for the very broad question "how to transform an existing php driven site to MODX" here’s a few steps (in somewhat random order) you should be taking:
      - Setup your template(s) which tell MODX how to display your pages. This guide is quite detailed: http://bobsguides.com/porting-your-site-to-modx.html
      - Make resources for your pages where you enter the content, choose the right template.
      - Use snippets for dynamic content (menus, member area), processing etc
      - Enjoy the power and flexibility

      If you have any specific questions, do let us know.
        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.
        • 29522
        • 10 Posts
        Thank you for your answer.
        bobs guide has some interesting articles about modx, which makes a few things very clear to me.

        xPDO sounds interesting. I have heard of php’s PDO, but never worked with it.

        Does xPDO also mean i can connect to an Oracle database? I suppose not, but if it does, wow. (I have one client for an intranet based php application where only Oracle as a database is allowed)

        Where can i find more information about how to use xPDO?
          • 3749
          • 24,544 Posts
            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
            • 18373 ☆ A M B ☆
            • 3,141 Posts
            I think Revolution 2.1 will have some multi database support, however that may have been pushed back or I just misinterpreted something. The roadmap mentions it for 2.2 right now.
              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.