📜 ⬆️ ⬇️

Composite site: Bitrix technology in each CMS


Hello!
Let's talk about the most controversial body movement of the company Bitrix - technology "Composite site."
This is controversial because the guys have patented the technology, which, in my opinion, does not even draw on the coursework 3 courses of the profile specialty.


Well, okay, this is marketers.


The article reviewed:



All the goodies inside, under the cat.



Intro


Honestly, I don’t understand what was the point of patent technology for 1-2 hundred lines of code, and besides, it’s not at all innovative, this is really questions for the “patent bureau”, so don't care.
Let's go!


Technology composite site


Loudly, of course, call it technology, but let it be so.
What is it?
Quote from the site of Bitrix:


The unique production technology of sites combines the high speed of loading a static site and all the capabilities of a dynamic site.
The user instantly receives the page content.

They even promise acceleration 100 times , although benchmarks are not provided.
Well, this is again a question for marketers, and this, honestly, is not in my part.
The algorithm works as follows:



What is highlighted in red is executed in parallel.
I will not explain, everything is clear.


Usage example
/* *       */ $component->setFrameMode(true); $template->setFrameMode(true); /* *   */ $frameBuffer = new Bitrix\Main\Page\FrameBuffered("id_container_buffer"); $frameBuffer->begin(",     "); echo " "; $frameBuffer->beginStub(); echo " "; $frameBuffer->end(); /* *   */ $frame = new \Bitrix\Main\Page\FrameStatic("id_container_static"); $frame->setStub(",     "); $frame->startDynamicArea(); echo "   "; $frame->finishDynamicArea(); 

Code removed from the documentation and peeping into the source. Strongly did not go deep, but I do not need it, there is CompoJax. I did not try to launch in components, I will just say that it did not start on the pages and the template of the site. Who cares - can read the documentation, but, in fact, I do not advise, because after 9-page theoretical petting, you will see almost the same lines of code.


Compojax


Actually, the “technology” makes almost the same, only without pathos, patent, simpler, more transparent + PJAX.


The technology can be divided into 2 parts:



For the first, nothing is required, you can safely use it.
For the second component, you must have the jQuery and PJAX libraries .


The algorithm works as follows:



Actually, that's all.


Algorithmically, "technology" is not the same, so patent infringement, in principle, no. The patent did not go deep, but if a subpoena arrives I will do in the update article. Below are all the features of CompoJax, the PJAX settings and how to customize it. This code can be used everywhere, in components, templates, its classes, it does not matter.


Usage example
 use Jugger\Context\CompoJax; /* *  ,   */ if (CompoJax::begin("id_container")) { // ...content... CompoJax::end(); } /* *    */ $params = [ "loading" => "<img src='http://loader.gif' alt=''>", ]; if (CompoJax::begin("id_container", $params)) { // ...content... CompoJax::end(); } /* *  URL        *          */ $params = [ "url" => "/api/methodName?param1=...", ]; CompoJax::begin("id_out_container", $params); /* *      */ $js = <<<JS function(xhr, params) { // xhr -  XMLHttpRequest // params -    : id -  , url -      if (xhr.status == 200) { document.getElementById(params.id).innerHTML = xhr.responseText; } else { //   } }; JS; $params = [ "callback" => $js, ]; if (CompoJax::begin("id_container", $params)) { // ...content... CompoJax::end(); } /* *    PJAX      , *     , *      */ $params = [ "pjax" => [ //     compoJax  // "container" => "#id_container" [ "selector" => "a", //   ], [ "selector" => "form#pjax-form", "container" => "#pjax-form-contaner", //   PJAX (: https://github.com/defunkt/jquery-pjax#pjax-options ) "options" => [ "push" => false, "scrollTop" => false, ], ], //    , ..   'selector' [ "container" => ".fail-container" ] ], ]; if (CompoJax::begin("id_container", $params)) { // ...content... CompoJax::end(); } 

CompoJax is included in the Juggernaut libu, however, you can download it separately (only 1 class), links below.


Not just for Bitrix


As I mentioned above, this technology can be used not only in Bitrix, but also in any CMS.
In fact, you just need to inherit from CompoJax and overload the end and clearBuffer methods .


The first is for the output of dynamic content, the second is for cleaning the buffer of already output content.


Consider overloading these methods using the example of WordPress :


 class WpCompoJax extends CompoJax { protected static function clearBuffer() { /* *  WP     , *      */ } public static function end() { ob_end_flush(); self::processPjax(); //    PJAX ,      PJAX wp_die(); } }; 

Well that's all.


In principle, everything is ready, everything is cool, everything works. It remains only to add caching and in general it will be great. It will be added soon, perhaps.


Juggernaut : https://github.com/irpsv/juggernaut.bitrix
CompoJax : long github link


')

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


All Articles