📜 ⬆️ ⬇️

Integration of web services into popular cms

In this article, we will give recommendations on how to master cms in a short time and write an extension, module or plugin for it, and also tell you about the results and our experience of integrating the Cackle service into these systems. The article can be a guide for those who are going to integrate services with cms systems or simply create a module.

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

Based on these statistics, we can assume that the effect of embedding your module in these cms will be statistically proportional to their popularity. Is this for each cms, we will know further.
')
Integration allows you to conveniently integrate services into 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 - instruction on how to finish cms, at which cms scripts are changed. For our project, any integration of Cackle comments for cms usually includes the following items:

- Synchronize comments from the Cackle service to the local database every 5 minutes
- Display html for SEO
- Export existing comments on the site to Cackle
- Ability to resynchronize (re-copy comments in the local database)
- SSO (authorization of its users)
- Count of comments on the main page
- Recent comments widget

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

We did integrate 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 a well- documented 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 js counter to footer. For time synchronization, we use the wp_schedule_single_event function that implements the launch of any function by timer.

To familiarize yourself with the code, download the plugin and see the description here - a wordpress plugin

Testing

Testing for WP should be carried out on different versions, because It is possible that there will not be any function or table in the database used in your module. Here you can do the following check:
if (version_compare(get_bloginfo('version'), '2.9', '>=')){
..
}

Do I need to support older versions? I think yes. Many bloggers are sitting on old versions, because The update often ends with the change of the template files, the engine, many plugins stop working and you have to set everything up again.

Release

The plugin release is commited to the svn tag with the correct version. Particular attention should be paid to the version of the module that is put in the main file and the readme file. The module is released without any moderation. Time to provide access to svn WordPress somewhere 3-5 days.

results

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

Drupal


Development

Initialization occurs from 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 correctly transfer variables 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 mcSite itself will be obtained already from the preloaded properties 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) ); 


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


You also need to pay attention to the fact that these hooks are connected only when you remove and reinstall the module.

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

Release

Zarelit module in the directory on the site of drupal was a rather difficult quest. First a sandbox project is created. Filled in git. Then he goes to review. On this project, they attach like kites. The first thing browsers will write about are errors and warnings of automated code checking - pareview.sh . Everything is important before the space, and to the comma, 2 spaces instead of tabs, etc. And so before each edit code. Then, after everything has been fixed and you report enough about it, then a certain “main one” appears and writes: We’re quite busy now, and link to review bonus at drupal.org/ node / 1975228 the essence of which is that before you get a review from a person who can upgrade the project from the sandbox in full project - i.e. a project that will be available in the catalog, you need to make 3 reviews of other projects. If bugs are found, the project is sent for revision, and you need to make another 3 reviews before you can put a bonus review tag.

What the reviewers pay attention to first:

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

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 the personal account. According to our statistics, now the Drupal module is used somewhere on 150 sites.

Wix


Wix is ​​a popular website builder. The developers of this site builder contacted us themselves and offered to make an application for their marketplace. It was attracted by the fact that over 30 million sites were created on their platform, although in Russia it is still exotic (we did this integration back in April and we did not have statistics on domains in Russia).

Development

In order for the widget to get into the marketplace, you need to create several controllers on your hosting service that accept encrypted parameters and display the corresponding widgets. When creating a Wix application itself, only 2 addresses are inserted: / widget - the widget itself, / settings - the 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, because even the recent prefix gives the old API library.

Release

Problems that can be encountered when submitting an application to the market:
- It is required that the user registration in the service takes place directly on the wix website, through these very widgets that need to be generated on your server
- You can not require confirmation of registration in your service
- All settings of our widget should not be made on Cackle, but 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 site Wix
The first 3 are based on the idea that the user should stay on their site, and should not go to the post office or God forbid to do the settings on another site.
The latter comes from the fact that Wix receives a reward in the region of 30-40% for your sales.
All attempts to explain that everything works wrong for us, and that we will have to substantially change our system, receive one answer: “In Wix it's different”. And apparently they are proud of it.
As a result, they refused to place in the market, limited to instructions for their users, who are already our clients and they have Wix.

DLE



Development

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


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

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

Release

The most pleasant reward that waited at the end is that DLE turned out to be dozens of sites (easily searched by search), where you can completely FREE to post information about your module ... and these are good sites with an attendance of 500-3500 people per day. Also completely free of charge, our module was posted on the main page of dle-new.ru. All this brought very good conversion traffic.

Development time

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

Result

150 installations per month

InstantCms



Development

There are no official documentation on creating plugins. Instead, it is proposed to look at the finished modules. Lists of event lists are scattered online (here’s 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 in the code, because Many events have small bugs and may not return an object with html to which you can add your piece or not work at all. Only for the following types of content we managed to embed our code: articles, blogs, fotos.
The admin with the configuration of the plugin had to be screwed along the plugin's 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 - instantCms plugin

Release


This cms was a decent number of requests for integration from customers, but looking at the statistics of this cms, we were in no hurry to do the integration. The module ordered one of the clients. We did the indexing setup, and the client placed the module in the instantCms blog. Further, we included all other possibilities in this module (export, sso, counter) and added to the list of plugins. We planned to be able to place information on this module on thematic sites and forums, but with a more serious look, we realized that there were none. In addition, reviews and discussions on the blog are reduced to the feasibility of using paid services in the light of the fact that users use free cms.

Development time

3 days. The main time was spent on figuring out how events work.

Result

With a dozen installations.

Joomla


Development

There is official documentation for creating a plugin. Parameters for the plug-in are defined via xml, localization through the system of convenient messages. There are convenient events docs.joomla.org/Plugin/Events/Content before and after the content is displayed . For convenient testing and development, you should deal with the types of content, create all basic types of content in a test -

$ view == 'article' for the content component
$ view == 'item' for component K2
$ view == 'productdetails' for viruemart
$ view == 'frontpage' for the main page
$ view == "featured" for favorites
$ view == 'section' and $ view == 'category' for categories
Further, during the development of events, you can determine the type of content and the component name, and output the necessary elements for the module under normal conditions.
$ view = JRequest :: getCmd ('view'); $ option = JRequest :: getCmd ('option');

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

Testing

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

Release

Separately worth noting joomla extention dir. Firstly, they have bugs with a 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 subsections. Slightly unusual module submission form. The lineup a month ago, with the new release was 86, this month moved by 70. This month already 216 applications are in the queue.
For us, the goal of developing this solution was to abandon third-party plug-ins.

1C bitrix


Development

At the beginning of the application deployment, the complexity of installing to utf-8 arose. It took a long time to configure the server.
Documentation for the development of modules is excellent with a description of the structure of the module and examples. For integration into bitrix it is common to create a module with a component. 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 ID in the form of block_id. Instead, I had to use the GetCurPage () function to return the path for the material. In the admin panel of the module, our admin panel of the general solution easily fell with a slight change in the function preserving parameters:
 COption::SetOptionString("cackle.comments", $param, $value); COption::GetOptionString("cackle.comments", $param); 

View the code while you can only in the admin Cackle. To do this, you can use the demo registration .

Release

For release, you must send an application to the partnership. 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 responded so that development could be carried out on a demo version that lasts 30 days.
When the release 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 Settings and Updates, as well as in the Settings of the modules (if option.php exists), and if without a dot, then in the modules the bitrix. In the marketplace moderation takes quite a long time: 7 days on average (according to those. 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 got 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), it was necessary to rewrite the entire database layer on the Bitrix API. Now the module is again in moderation, and it looks like when finalizing the module is again at the beginning of the queue.

Latest recommendations



General recommendations for quick and successful integration:

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

We do integration with cms because This improves the quality of work with clients. We always have the opportunity to help the client in case of problems.

Next, we plan to do integration with other cms. In the near future it is Netcat and UMI. If this topic is interesting, then we continue to continue to describe the integration.

Source: https://habr.com/ru/post/195136/


All Articles