A Bunch Of MODx Revolution + LiveStreet

When going to write your topic, puzzled where to write it? On the one hand part of the site written in MODx, on the other hand the other part written on LiveStreet, and on the third hand these are crutches that at the time of Abnormal programming to write. It turned out that the Habr was preparing for such an eventuality and made the ability to write to multiple blogs, separate respect! :-)

Well, now actually to the basic question: At the time I wrote and launched coupon service itself is written in MODx Revolution (of course, because I am an ardent fan of this engine and whatever you read, always write on this framework).
So, the project grew and developed a lot of functionality, it was written (the benefit of MODx allows to solve any problem), but that's just me zamisliti on the site and more social programs-blog a La ... run, yeah to all of our users were there, Yes to reviews stock there got, the reviews were in stock, and in the social sphere, and here and there they could comment and read them in a separate thread all pile up, and many more things... And when I thought how much I will need time to programmed it all myself, I was made very sad...

But I remembered about LiveStreet about which I heard a long time ago, and the fact that it is marketed as a quick and easy clone of Habra. I decided a separate social sphere to pick up on the LS and linked it with my main website on MODx. LiveStreet set and ran for a couple of hours (this is my first experience with this engine).

Looking ahead, here's a tip: if you decide to repeat the same, when to deploy LS Buda, the tables give a unique prefix based on the table prefix of MODx. For example, if you have to MODx prefix modx_, then LS give something like modx_ls_, so you can add your module MODx and create the schema with the given prefix, to be able without crutches to work with tables LS. By the way, you can be useful this the topic.

Next, edit the template, user registration, banning it in direct registration on the website, putting the user that is necessary to register on the main site, not here. To understand, we note that MODx it will be the main pro-cent.ru LS forum.pro-cent.ruIn General, further MODx in table modx_users add the key to the plate ls_users that then means MODx is easy to apply LS to the user via the user record MODx.

Honestly, I'm still not super know LiveStreet, and yet seriously considered the option of a single users table once and for MODx and for LS, but in principle, I have configured the secondary key to a table lock when deleting that ensures data integrity at the database level, and overall problems even with separate tables of users does not occur.

In General, then you just have to register your API to interact with the MODx LS. Someone might write it using require 'LS/public_html/index.php' I have all through the POST via CURL with the transfer of the required parameters and key to protect the queries, so a robot doesn't spawn you anything :-)

I will not now be given in detail as it's all done, as the topic no longer written as a specific manual, but for the overall development, but if someone has an idea like that and someone wants to crank and such, Wellcome, questions in the Studio, I will answer.

PS Forgot to say that MODx still activity from the social sphere is displayed. If you go on the main website, you'll see it in the right column.

P. P. S. Here we have a complaint that still need technical points to describe in more detail. Well. Describe the General scheme of the API that I used to communicate basic site with LS.

I must say that LS is a pretty original engine, and very active use of noSQL as a basis for caching, because it is not recommended to work directly with the database of the social sphere and to work through his Actions (I'm not going to write here a master class in LiveStreet, you have to learn on their own).
As a billet for everything else, describe the procedure to create a topic and comment, by requesting from the main website.
First, in LS you add your Action, through which we call the query. To do this, create a module-config, for example config/modules/modx (we will need it in the future for all queries) and create a file config.route.php. We'll need to configure the URL-s for the engine.In it write the following:
$config['page']['modxtopic'] = 'ActionModxTopic';
$config['page']['modxblog'] = 'ActionModxBlog';
return $config;


This configuration will need the engine, to determine the URL-what action to perform. In this case, the URL-s in /modxtopic and /modxblog. When you access this URL-am will be called action classes /classes/actions/ActionModxTopic.class.php and /classes/actions/ActionModxBlog.class.php, respectively.
Of course you have to create for themselves the necessary classes in the image and likeness, plus, have and the template files according to the principle /templates folder (usually /templates/skin/skin of site)/action/your Action (in this case ActionModxTopic or ActionModxBlog)/index.tpl or action.tpl
In General, it's all you'll have to practice to learn, because in three lines to describe.

I thought these classes have to overload the base classes of the LS, because LS itself does not give API for such actions, and the basic functionality is designed so that the user was authorized and it was impossible from the outside to overwhelm the user. It does not want to write extra code and to understand the caching system, etc.
In General, we want to add the topic. Work with topic is performed through /classes/actions/ActionTopic.class.php with commentary through /classes/actions/ActionBlog.class.rssda your class, you overload a base class, and write in the Init() function and the function called action, for example SubmitComment() class maintains the Blog comments.

Unfortunately there's some stuff going on with transfers, because you can not paste fine 200 lines of code in your class where everything is written, therefore will have to continue to understand ourselves. However a file with the class code posted here. There may have something extra, but in General terms you can understand will. There are no comments.

Strictly speaking in General terms and is running.
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

March Habrameeting in Kiev

PostgreSQL load testing using JMeter, Yandex.Tank and Overload

Monitoring PostgreSQL with Zabbix