Easy ways to convert a MYSQL-connected dynamic PHP site into a CMS?

(I don’t know the best way to word this but here goes!)
I have a site that is in PHP and it grabs certain data from tables depending on an identifier input like .php?id=500 and looks up from each table grabbing each respective fields and putting them into tables or lists.

What is the best easy CMS that I would use? How would I approach this? Is there a simple plugin for something like Joomla or WordPress or the such I can point to specific tables, tell it the identifier column, and tell it to list every row that matches? Including other tables?

Read More

IE. It pulls something from address table and lists all their address, pulls something from information and lists their gender age, and etc.

So this way, it creates dynamic pages that I can manage a lot easier and have searches and indexes. Trying to code all that and it’s getting way ahead of me. I figured there’s a CMS that does all this for me.

I hope you guys understand my question, I tried searching many wordings of this.

Related posts

Leave a Reply

11 comments

  1. You’re making the right decision. Move to a CMS.
    I have successfully migrated data (categories, articles and images) into a Joomla installation, the steps are:

    1. select from your CMS
      relevant data
    2. if pictures are stored separately from articles in your CMS, prepend at least one

      to the text and append the rest;

    3. J2.5+ has support for article image and thumb, but templates still don’t implement it
    4. Unless you need fine-grained access at the article level, point all
      articles to a single Asset ID
    5. Create a sample article and use the
      extra fields to fill-in-the-blanks
    6. Use proper separation of IntroText and FullText if possible; make sure the html that goes into each is self-contained and validates
    7. Verify your data is in UTF-8 (else convert it) then run the SQL import
    8. From the article manager choose the rebuild icon to rebuild assets and ltr-rtl fields

    To perform the SQL Import you need to also clear the content_frontpage table.

    Here is a function that receives a row from another cms and puts it into Joomla; a few comments are in Italian but you should get a feel of how to do it.
    mdc2j are dedicated functions I wrote to proper escape the data and change formats/category ids etc. as needed.

    function importaArticolo($row) {
        global $link;
        echo "<h3>Importa Articolo ".$row->Id . " (". $row->titolo . ")</h3>";
    
        /*
            " ('$row->id', '0', 'test', 'test_alias', '', 'tutto il testo riga per riga', ".
            "  '', '0', '0', '0', '111', '2001-01-25 16:30:15', '4', 'la firma', '2001-01-25 16:30:15',  ".
            " '0', '0', '0000-00-00 00:00:00', '2001-01-25 16:30:30', '0000-00-00 00:00:00', 'list of images?', 'list of urls?',  ".
            " '".'{"show_title":"","link_titles":"","show_intro":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_icons":"","show_print_icon":"","show_email_icon":"","show_vote":"","show_hits":"","show_noauth":"","alternative_readmore":"","article_layout":""}'."', ".
            "  '1', '0', '0', 'kewords', 'key-description',  ".
            " '0', '0',  ".
            " '".'{"robots":"","author":"","rights":"","xreference":""}'."', '0', '*', '');";
            */
        try {
            $idcategory = mdc2jCategory($row->idCanale);
            if ($row->isDossier * 1 == 1) {
                if (1*$idcategory==10) {
                    $idcategory= 28;
                }
            }
            $default_user=42;
            $SQL=sprintf(
                "INSERT INTO `".$GLOBALS['db_database_new']."`.`eco_content` (`id`, `asset_id`, `title`, `alias`, `title_alias`, `introtext`, ".
                " `fulltext`, `state`, `sectionid`, `mask`, `catid`, `created`, `created_by`, `created_by_alias`, `modified`,  ".
                " `modified_by`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `images`, `urls`, `attribs`,  ".
                " `version`, `parentid`, `ordering`, `metakey`, `metadesc`, `access`, `hits`, `metadata`, `featured`, `language`,  ".
                " `xreference`)  ".
                " VALUES  ".
                " ('%d', '0', '%s', '%s', '', '%s', ".
                "  '%s', '%d', '0', '0', '%d', '%s', '%d', '%s', '%s',  ".
                " '0', '0', '0000-00-00 00:00:00', '%s', '0000-00-00 00:00:00', '', '',  ".
                " '".'{"show_title":"","link_titles":"","show_intro":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_icons":"","show_print_icon":"","show_email_icon":"","show_vote":"","show_hits":"","show_noauth":"","alternative_readmore":"","article_layout":""}'."', ".
                "  '1', '0', '0', '%s', '%s',  ".
                " '%d', '%d',  ".
                " '".'{"robots":"","author":"","rights":"","xreference":""}'."', '%d', '*', '');",
            $row->Id,
            mysql_real_escape_string($row->titolo),
            makeAlias($row->titolo), // alias
            mdc2jSommario($row), // this creates the introtext
    
            mdc2jText($row), // this returns the text
            $row->idStato=="2"?0:1, // idStato="suspended"
            $idcategory, // correct category id
            mdc2jDate($row->dataCreazione),
            $default_user,
            mdc2jFirma($row->firma),
            mdc2jDate($row->dataCreazione), //2001-01-25 16:30:15
            mdc2jDate($row->dataPubblica), //2001-01-25 16:30:30
    
            mdc2jMetaKeywords($row), // adds "dossier" if appropriate
            mdc2jMetaDesc($row), // if not assigned, create it automatically
            $row->idStato=="2"?3:1,
            $row->viewCounter,
            0 //featured: (($row->Id % 13) == 0 ? 1 : 0 )
            );
    
    
            $res = mysql_query($SQL);
    
            if ($res) {
                $lastid = mysql_insert_id();
                //echo "Article $lastid ($row->Id) Inserted into DB<br>";
                        // this will import images in a separate tool, an ignite gallery, so it's not really meaningful for you:
                importaImmagini($row->Id, $row->canale, $row->cid);
    
    
                return 1;
    
            }
            else {
                echo "<span class='err'>WARNING: article not inserted in db</span>"."<br>".mysql_errno($link) . ": " . mysql_error($link);
                echo "<textarea cols='80' rows='3'>".$SQL."</textarea><br>";
            }
    
            return 0;
    
        }
        catch (Exception $e)
        {
            echo "<span class='err'>Exception! ".$e->getMessage()."</span><br>";
            return 0;
        }
    }
    
  2. There are a LOT of CMS solutions that can do this for you. To be honest, if you already have a site up and running and you just want a CMS, Joomla or WordPress is sort of overkill. Have a look at PyroCMS, it does exactly what you’re describing. It’s very easy to set up and get running and has good documentation.

    If you’re into Python and interested in a hybrid solution, I’ve had success using PHP frameworks for main sites and Django (which is in Python) for the CMS.

  3. This really wouldn’t be that complicated to write yourself. In fact, it’s similar to how one of my content management systems works: I have a class for each “module” and properties that specify the database table to select records from, the columns to show on the overview page (table headings), and the columns to show in the form view (inputs).

    Trying to shoe-horn an already-built website into a CMS like WordPress or Joomla! that is wanting to do everything for you (including the front-end site) out of the box is going to be a pain in the ass. And even if you do shoe-horn a CMS onto your site and get it working, it’s going to be bloated as hell.

  4. Another idea might be to use Cakephp http://cakephp.org/. Cake can read your database schemes and produce the files that you need to get up and running. (If you have command line access). It uses the MVC pattern and its pretty quick to set up. I’v personally used cake on number of projects that you are describing.

    WordPress might be a bit hard to get all your posts into without doing it manually. But if you don’t want to code too much and are will to manually move everything wordpress or some other out of the box CMS system might be the thing for you.

  5. Nice question. Since Joomla is answered I will answer for WordPress. I would suggest creating a php file that exports all your table data to xml (RSS or WordPress). Then you can simply import your info into WordPress using WordPress import function.

    This way you can keep both the tables and you can fully import info into WordPress.

    If your interested I could probably cook some code together if you give me the format of your tables.

    Finally you should search for and repost your answer on WordPress Stack Exchange ( wordpress.stackexchange.com).

  6. There are four question marks:

    Q. What is the best easy CMS that I would use?

    A. WordPress.

    How would I approach this?

    A. Learn PHP.

    Q. Is there a simple plugin for something like Joomla or WordPress or the such I can point to specific tables, tell it the identifier column, and tell it to list every row that matches?

    A. Probably. This is a simple task in PHP.

    Q. Including other tables?

    A. Ditto.

  7. Here are some possible shortcuts for what you’re trying to accomplish:

    If your current site is generating an RSS aggregation link, then WP-RSS-Multi-Importer looks promising.

    If your current site doesn’t have RSS, but you have access to the database (via a hosting control panel / phpmyadmin, or via a server command line utility like mysqldump), then you can export the database as CSV or XML and try to import it into WordPress with a plugin like WP-All-Import.

    This will take a little more time, since you’ll need to map the data to the appropriate wordpress fields.

    If you have neither RSS nor access to the database, then you’re going to need to “scrape” your site. Usually this means coding, but there are several wordpress plugins that might work for you. A lot can go wrong here, so don’t be surprised if the final product isn’t what you want.

  8. You can use a framework like yii or codeigniter. They can make your life very easy. You can make CMS very easily and quickly using these framework.

    You can pass the parameter like id