0
votes

I have many PHP application (and other than PHP too) which are not very suitable to be build on top of CMS due to complexity of the application or legacy implementation. What would be good way to get CMS functionality into the application? In the past I have been using HTML snippets on server side which are included to the pages Snippets are maintained via HTML tools like Dreamweaver or CushyCMS. That allows me to have some content areas which admin can maintain. However I'm not very satisfied to CushyCMS (nor standalone DW) since it's limited capability. I have been thinking using Wordpress of similar just to maintain content which is directly included to the pages on server. But the actual questions is... :)

What would be the good way to get CMS functionality without building whole site with CMS like Wordpress or similar.

2

2 Answers

1
votes

There is a reason why CMS becomes complex - you start off by adding simple article management being saved to either file, or sqlite.. then you need several users.. then a tree-like menu, a permission system, an article locking or version control.. then you want better performance and scalability, so you migrate to real DB.. Then you want dynamic data like widgets or tables. Then modular structure. A shop module, newsletter, etc. And so you endup with a complex engine that only you know how it works.

So if you want a maintainable CMS in a long run, use existing opensource solutions, even if they are ugly on the inside like Wordpress. You might need to integrate one into another, thats where you'll need API on both sides.

0
votes

Well, something you could do is to create a CMS extension which handles a route in the CMS and then delegates the result to the underlying application.

To give you an example, lets think in drupal 7. In this CMS you may create a module with a folder that contains two files: one for data about your module and one for the module's code.

my_module/my_module.info <-Module's data

name = My Module
description = A description of what your module does.
core = 7.x

my_module/my_module.module <- Module's code

<?php
/**
* Respond to a drupal's URL with a callback.
*/
function my_module_menu() {
    $menu = array();
    $menu["App"] = array(
        "page callback" => "my_module_run",
        "access callback" => true,
    );
    return $menu;
}

/*
* Do the job
*/
function my_module_run() {
    ob_start();
    // Call your application by including it's index.php file or whatever
    // operation needed.....
    // Capture the result of the application.
    $result = ob_get_clean();

    // If the request is ajax, echo the result.
    if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) 
       && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
        echo $result;
    } else {
        //Otherwise, return it, so it is rendered as part of the 
        // CMS content.
        return $result;
    }
}
?>

With this basic code you may "integrate" your applications to drupal, all you need to do is to install it as any drupal module and then go to htt://your-cool-site/App to execute your application.

More on drupal module authoring here.

I hope it helps :)

Here is a framework that works having this in mind, it has bindings to drupal (6, 7 and 8) and joomla.