Integration of web services in popular cms

    In this article we will give recommendations on how to learn cms in a short time and write an extension, module or plug-in for it, and also talk about the results and our experience of integrating Cackle service into these systems. The article can become a guide for those who are going to do service integration with cms systems or just create a module.

    Before deciding which cms to do integration with, it’s worth collecting statistics on requests for integration of your users, as well as looking at general statistics on cms on the sites of the .RU zone (http://statonline.ru/metrics/webapp_cms?tld=en) which shows which cms are the most popular.
    image

    Based on these statistics, it can be assumed that the effect of embedding your module in these cms will be statistically proportional to their popularity. Is this true for each cms we will learn further.

    Integration allows you to conveniently embed services in cms and maximize the benefits of its use. The ideal solution is to install the plugin in a few clicks. An acceptable solution may be a mod - instructions for completing cms, in which cms scripts are modified. For our project, any integration of Cackle comments for cms usually includes the following points:

    - Synchronization of comments from the Cackle service to the local database every 5 minutes
    - Display of html for SEO
    - Export of existing comments on the site to Cackle
    - The ability to resynchronize (re-copy comments to the local database)
    - SSO (authorization of its users)
    - Comment counter on the main page
    - Last comments widget

    All these requirements for the module include the implementation of a timer, receiving comments by request through the API, saving to the database, displaying the widget js in cms templates on certain pages and the admin panel for entering API keys, and other settings.

    We have integrated our Cackle comment service into the following cms systems:
    Wordpress, Drupal, DLE, InstantCms, Joomla, Bitrix.

    Now, in chronological order, we describe our integration experience for each cms.

    Wordpress



    Development

    There is well-described documentation for creating a plugin . To initialize the plugin, just find the necessary hooks: actions and filters - codex.wordpress.org/Plugin_API . We use comments_template to display our template with comments, comments_number to display the number of comments for posts, admin_menu to add a menu to the admin panel, and wp_footer to add a js counter to the footer. To synchronize in time, we use the wp_schedule_single_event function that implements the start of any function by timer.

    To get acquainted with the code, download the plugin and see the description here - plugin for wordpress

    Testing

    Testing for WP should be carried out on different versions, as a situation is possible when there is no function or table in the database used in your module. Here you can do the following check: Do I need to support older versions? I think yes. Many bloggers are sitting on older versions, because the update often ends with changing the template files, the engine, many plugins stop working and you have to configure everything again.
    if (version_compare(get_bloginfo('version'), '2.9', '>=')){
    ..
    }



    Release date

    The plugin release is committed to the svn tag with the correct version. Particular attention should be paid to the version put in the main file of the module and readme file. The module will be released without any moderation. The time for granting access to svn WordPress is about 3-5 days.

    results

    For wordpress, there is open statistics on the use of the plugin at a particular point in time - wordpress.org/plugins/cackle/stats . Immediately after the release, there were 30-50 downloads per day. Currently, the total number of downloads is about 20,000. 80% of users are our customers.

    Drupal


    Development

    Initialization occurs with the block display hook on the _block_view () page. Particular attention should be paid to connecting the custom template and adding a js file. It is important to pass the variables correctly so that they can be used.
    To connect js:
    drupal_add_js(array(
          'cackle' => array(
            'cackle_mc_site' => variable_get('cackle_mc_site', NULL),
            'node_id' => $node->nid,
          ),
      ),
      'setting');
    

    Inside js itself, mcSite will be obtained from the preloaded property of the Drupal object:
    var mcSite = Drupal.settings.cackle.cackle_mc_site;
    

    The template is connected as follows:
    $template = theme('cackle_custompage_template', array( //передача переменных в шаблон
            'obj' => $obj,
            'nodeid' => $nodeid,
            'has_curl' => $has_curl)
        );
    


    Sam hook template:
    function cackle_theme() {
      return array(
        'cackle_custompage_template' => array(
          'template' => 'cackle_template',
          'arguments' => array(
            'obj' => NULL,
            'nodeid' => NULL,
             'has_curl' => $has_curl
           ),
        ),
      );
    }
    


    It is also necessary to pay attention to the fact that these hooks are connected only when the module is removed and reinstalled.

    To familiarize yourself with the code, download the plugin and see the description here - module for drupal

    Release date

    To get the module into the directory on the drupal website turned out to be a rather difficult quest. First a sandbox project is created. Poured into git. Then he goes to review. This project is being thrown like kites. The first thing that browsers will write about is errors and warnings of automated code verification - pareview.sh . Everything is important up to a space, and to a comma, 2 spaces instead of a tab, etc. And so before each editing of the code. Then, after everything is fixed and you report quite a bit about it, then a certain “main” appears and writes: We are quite busy now, please help us to review and we find time to review your project and a link to review bonus drupal.org/ node / 1975228the essence of which is that before receiving a review from a person who can upgrade a project from sandbox to fullproject - i.e. the project, which will be available in the catalog, you need to do 3 reviews of other projects. If shortcomings are found, the project is sent for revision, and 3 more reviews need to be done before the bonus review tag can be put.

    What reviewers pay attention to first of all:
    • To work with the database, you must use the native API
    • it is strictly forbidden to generate pure html in the module, for this you need to use the template
    • check for XSS when displaying html with the check_plain () function
    • configure module permissions correctly - access arguments

    You can see here how it was - drupal.org/node/1824770
    In order to get a bonus review, keep your finger on the pulse ... as soon as a new project for a review appears, you need to quickly merge and look for errors and inaccuracies from the top list. If you have completed all this, then your account will be given the right to create full projects without community moderation. And the last warning: it’s not possible to get the right to create full projects by posting a small project in a few lines for review, with the aim of later increasing functionality but without moderation.
    I also want to note that in the api description you can find a lot of errors in order to understand how this or that hook works, it is better to look at drupal core modules right away.

    Result

    For all the time there are only 241 downloads from the catalog - drupal.org/project/cackle and about 100 downloads of the demo version from your personal account. According to our statistics, the Drupal module is now being used somewhere on 150 sites.

    Wix


    Wix is ​​a popular website builder. The developers of this site builder themselves contacted us and suggested creating an application for their marketplace. It was attractive that more than 30 million sites were created on their platform, although this is still exotic in Russia (we did this integration in April and we did not have statistics for domains in Russia).

    Development

    In order for the widget to get into the marketplace, you need to create several controllers on your hosting that accept encrypted parameters and display the corresponding widgets. When creating the Wix application itself, only 2 addresses are inserted: / widget - the widget itself, / settings - widget settings. They have a ready-made example on php - github.com/wix/wix-php-rss-feed-app , which helps to raise this application on their hosting. Only you need to carefully replace the current library, tk. even the recent prefix gives away the old API library.

    Release date

    Problems that you may encounter when submit'e applications to the market:
    - It is required that user registration in the service takes place directly on the wix site, through these very widgets that need to be generated on your server
    - You can not require confirmation of registration in your service
    - All settings are ours the widget should be produced not on Cackle, namely in the Wix application itself
    - If you have your own tariffs, then they should be transferred to Wix, i.e. Pay for your services will be on the Wix site.
    The first 3 come from the idea that the user should stay on their site and should not go to the mail or God forbid to make settings on another site.
    The latter assumes that Wix receives a reward in the region of 30-40% for your sales.
    For all attempts to explain that everything doesn’t work for us, and that we have to significantly change our system, one answer comes: “In Wix it's different”. And apparently they are proud of it.
    As a result, they refused to post in the market, limiting themselves to instructions for their users, who are already our customers and they have Wix.

    Dle



    Development

    The API for DLE is the shortest of all. Of course, there aren’t such powerful hooks as in drupal and wordpress, but by minor changes to the code you can neatly embed the module you need.
    The developed module is connected in one line in the desired template -
    {include file="engine/inc/cackle_template.php?newsid={news-id}"}
    


    This allows you to test the module in isolation from cms and only then build it in. In fact, in dle, we built our general solution. The module itself is installed by calling the module admin page: example:
    http: // [root path of the site] /admin.php?mod=cackle_admin
    The database constants defined in dle (DBHOST, DBNAME, DBUSER, DBPASS) made it possible to fully use the general solution and database connections made through pdo.

    To familiarize yourself with the code, download the plugin and see the description here - module for dle

    Release date

    The most pleasant reward that awaited in the end is that there were dozens of sites on DLE (easily searchable by search), where you can post information about your module absolutely FREE ... and these are good sites with traffic of 500-3500 people per day. Also, completely free of charge, our module was placed on the main page dle-new.ru. All this brought very good conversion traffic.

    Development period

    3 days including the development of a general solution with the admin on ajax and support for 2 encodings (utf8, win1251)
    Release time: within a week

    Result

    150 installations per month

    Instantcms



    Development

    There is no official documentation for creating plugins at all. Instead, it is suggested to take a look at the finished modules. The network scattered lists of events'ov (here is one of www.instantcms.ru/blogs/haki-patchi-moduli-plaginy-i-prochie-dorabotki-dvizhka/spisok-vseh-event-ov-sistemy.html ) But it's better to watch into the code, because many events have small bugs and may not return an object with html to which you can add your own piece or not work out at all. Only for the following types of content we managed to embed our code: articles, blogs, fotos.
    The admin panel with the plugin settings had to be fastened along the plugin path:

    foreach($GLOBALS['cp_pathway'] as $key => $value){
                if(isset($GLOBALS['cp_pathway'][$key]['title'])) {
                    if ($plugin_id&&$plugin_name='p_cackle'){
                        $this->events[]                 = 'SHOW_CACKLE_ADMIN';
                        cmsCore::callEvent('SHOW_CACKLE_ADMIN', $this->showCackleAdmin());
                    }
                }
            }
    


    To familiarize yourself with the code, download the plugin and see the description here - plugin for instantCms

    Release date


    There were a decent number of integration requests from clients for this cms, but looking at the statistics of this cms we were in no hurry to do the integration. The module was ordered by one of the customers. We did the indexing setup, and the client posted the module on the instantCms blog. Next, we included in this module all other features (export, sso, counter) and added to the list of plugins. We planned that we could post information on this module on thematic sites and forums, but with a more serious look, we realized that there were none. In addition, the reviews and discussions on the blog came down to the usefulness of using paid services in light of the fact that users use free cms.

    Development period

    3 days. Most of the time was spent figuring out the events.

    Result

    With a dozen installations.

    Joomla


    Development

    There is official documentation for creating the plugin. Parameters for the plugin are defined through xml, localization through a system of convenient messages. There are convenient events docs.joomla.org/Plugin/Events/Content before and after the output of the content. For convenient testing and development, you should understand the types of content, test all the main types of content -

    $ view == 'article' for the content component
    $ view == 'item' for the K2
    $ view == 'productdetails' component for viruemart
    $ view = = 'frontpage' for the main page
    $ view == "featured" for the selected
    $ view == 'section' and $ view == 'category' for categories
    Further, in the course of processing events, you can determine the type of content and the name of the component, and display the elements necessary for the module in the usual conditions.
    $ view = JRequest :: getCmd ('view'); $ option = JRequest :: getCmd ('option');

    To familiarize yourself with the code, download the plugin and see the description here - plugin for joomla

    Testing

    We tested on two versions 2.5, 3.0 with components k2, Virtuemart (not for 3.0)

    Release date

    We should also mention joomla extention dir. Firstly, they have bugs with login there ... not all forms work ... different registrations on the forum and on the site. The submission button of the plugin is located in the directory itself in the subsections. A bit unusual form of submission module. The line a month ago, with the new release was 86, in a month it moved to 70. In the current month, 216 applications are already in the queue.
    For us, the goal of developing this solution was to abandon third-party plugins.

    1C bitrix


    Development

    At the beginning of the application deployment, it became difficult to install on utf-8. I had to configure the server for a long time.
    The documentation on the development of modules is excellent with a description of the structure of the module and examples. For integration into Bitrix, a module with a component is generally created. The component can be connected through the visual editor by the user on any page of the site. One of the problems was getting the material identifier as block_id. Instead, I had to use the GetCurPage () function that returns path for the material. Our admin panel of the general solution easily went to the admin panel of the module with a slight change to the functions that save the parameters:
    COption::SetOptionString("cackle.comments", $param, $value);
    COption::GetOptionString("cackle.comments", $param); 
    

    You can see the code so far only in the Cackle admin panel. To do this, you can use the demo registration .

    Release date

    For release, you need to send a partnership application. As a result, you are assigned the status of a technology partner. We hoped that it would be possible to get a free license for development, but support replied that the development should be carried out on a demo version, which is 30 days old.
    When releasing, it is important to comply with the name. We have this cackle.comments. It is interesting to note that with this name the module is visible only in the Settings and updates, as well as in the Module Settings (if there is option.php), and if there is no dot, then in the Bitrix modules. Moderation has been going on in the marketplace for a rather long time: 7 days on average (according to Tech. Support), and in fact even 9 days. We tried to reduce development time and use our library with a pdo connector in the database. As a result, the tester had an error, because this module was not activated, and under the conviction that not everyone has this module (although it comes with php 5.2), I had to rewrite the entire database layer to the Bitrix API. Now the module is again in moderation, and it seems that when finalizing, the module again appears at the beginning of the queue.

    Latest recommendations



    General recommendations for quick and successful integration:
    • Own your own flexible library
    • See how 2-3 modules of similar functionality are written
    • See the dock for the creation of the module, if any
    • If the docks are not enough to look at the CMS code itself and find the necessary events for module initialization
    • After implementation, test on different versions of cms and with different templates

    As a tool, we use the Openserver server with a separate folder for each cms.

    We ourselves do integrations with cms as this improves the quality of customer service. We always have the opportunity to help the client in case of problems.

    Further we plan to do integration with other cms. In the near future, these are Netcat and UMI. If this topic is interesting, then we will continue to further describe the integration.

    Also popular now: