Ready to build a news portal NewsModxBox



Two years ago, I wrote about the ready build an online store on MODX Revolution. This time it was made quite a few online stores on ShopModxBox (most of them forces third-party developers), and today the number of installations of the engine is 200-300 pieces per month. The project continues to evolve, getting to the core of a new useful functionality.

The main qualities that we note in ShopModxBox is the high performance, flexibility and minimal code (ShopModxBox is a solution based on the framework, MODX Revolution, and his own part of the code is literally 3-5 thousand lines of php + Smarty templates).

So the other day we released a new build NewsModxBox. Here, the basis is the same as in ShopModxBox, but the logic is tuned for news portals and media. The Assembly is sawn for real and is not a small news portal and largely corresponds to realities of the business logic of electronic and mixed media.

That, for example, is in NewsModxBox?
    the
  • a custom editor articles. joxi.ru/52a104ZhjqK720 among other things, there is such a thing as creating a new document in the pop-up window. I will say this: it was one of the most difficult tasks in it.
  • the
  • Custom media Manager database and direct filling of files. About it, I sometimes wrote, for example SDAs. With this editor can work hundreds of people and he would not die and hundreds of thousands of files.
  • the
  • Morphological search. Yes, he works there :) Although each individual project may need adjusting, depending on the specifics.
  • the
  • Business logic, sharpened by the realities of the news portals, with different groups of accesses, sending it to editing, etc.
  • the
  • Typography texts by Jevix
  • the
  • ask articles index links in them or not (if not, all links will be marked with rel="nofollow")
  • the
  • Finish unloading in Yandex news and Google news (special full-text RSS).
  • the
  • Custom page sitemap.xml for an unlimited number of documents.
  • the
  • Banner system.
  • the
  • tag Cloud.
  • the
  • Blog-the social component.
  • the
  • Widgets, currency and weather.
  • the
  • Integration with hh.ru (section Work). By the way, all the pages of Work Cushnie, and look for search engines as part of the site.
  • the
  • Rabid technical optimization. The engine is designed for hundreds of thousands of articles. On average, the server holds hundreds of users online. Conducted load testing, 75 000 entries and 2,000 users online are unable to put the server. Proff, joxi.ru/Dr8Ke8OIYgKlA6
  • the
  • Section for paid content subscription
  • the
  • Generate thumbnails from PDF for magazines
  • the
  • Affiliate links. This is useful when you program something to eat. Here's an example: joxi.ru/D2PjRW0SOZqWr3 joxi.ru/eAOqaVNf3K98mo
  • the
  • Additional topics. That is, an article can be placed into several categories.
  • the
  • clever system of news selection and standardization, which will not allow in a few places accidentally bring the same news.
  • the
  • Custom publishing. joxi.ru/a2XVypGu8kDerg
  • the
  • Authorization via social networks.

And many, many things.

the

some technical information.


Software


Almost all the logic is written in the processors. On their logic, I've been wrote here. Since then, their paradigm as a whole remains the same, but technically they have changed, becoming mostly class-based. Quite fresh and detailed article about the new processors and we use SDAs.

What is the charm of processors? First, in their extensibility. Don't have to produce repetitive pieces of code. Second, in their versatility. MODX-e, you can call them directly (from other scripts or Smarty templates) and via the connectors (Ajax requests, etc.). Third, the ease of debugging. For example, you can take a sample of articles in MODX-console.
PHP code for a query in the console
<?php 
print '<pre>';
ini_set('display_errors', 1);
$modx- > switchContext('web');
$modx- > setLogLevel(3);
$modx->setLogTarget('HTML');

$namespace = 'modxsite'; // Namespace component

$params = array(
"limit" = > 3,
);

if(!$response = $modx- > runProcessor('web/resources/articles/getdata',
$params
array(
'processors_path' => $modx- > getObject('modNamespace', $namespace)->getCorePath().'processors/',
))){
print "failed processor";
return;
}


print_r($response->getResponse()); 


an Example response.
Array
(
[success] = > 1
[message] => 
[count] = > 3
[total] => 28
[limit] => 3
[page] => 0
[object] => Array
(
[86981] => Array
(
[id] = > 86981
[type] => document
[contentType] = > text/html
[pagetitle] => Donald trump. Ah, the art of the deal.
[longtitle] => 
[description] => 
[alias] => kopiya-donald-tramp.-skill-zaklyuchat-sdelki
[link_attributes] => 
[published] => 1
[pub_date] => 0
[unpub_date] => 0
[parent] => 86915
[isfolder] => 0
[introtext] => This book is highly recommended reading for ambitious people aspiring to leadership.
[content] => 

At the time this book I was very much inspired. It is autobiographical, that is, from it you will learn a lot about the Donald trump. In the book attention is paid to the personal qualities of the leader. Himself Donald believes that many successful people achieved success not because of some knowledge, and for the most part because of certain personal qualities (ambition, commitment, responsibility, etc.). If you consider yourself a leader, you simply must read this book.

[richtext] => 1
[template] => 2
[menuindex] => 5
[searchable] => 1
[cacheable] => 1
[createdby] => 422
[createdon] => 1443280367
[editedby] => 422
[editedon] => 1443280510
[deleted] => 0
[deletedon] => 0
[deletedby] => 0
[publishedon] => 1443225840
[publishedby] => 422
[menutitle] => 
[donthit] => 0
[privateweb] => 0
[privatemgr] => 0
[content_dispo] => 0
[hidemenu] => 0
[class_key] = > modDocument
[context_key] = > web
[content_type] => 1
[uri] => rubriki/books/kopiya-donald-tramp.-iskusstvo-zaklyuchat-sdelki.html
[uri_override] => 0
[hide_children_in_tree] => 0
[show_in_tree] => 1
[properties] => 
[article_type] => 
[image] => lazy/images/65588288e12ab09ae49c8a6f7552e130.jpg
[article_status] => 2
[mssql_id] => 
[tags] => 
[pseudonym] => 
[news_list] => 1
[rss] => 1
[top_news] => 0
[mailing] => 0
[article_genre] => 0
[main] => 0
[fasturl] => 
[views] => 148
[hide_on_mainpage] => 0
[hide_adverts] => 0
[object_id] = > 86981
[tv_27_gallery] => 
[tv_30_sell_link] => [{"MIGX_id":"1","title":"\u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430 Ozon.ru","link":"http:\/\/www.ozon.ru\/context\/detail\/id\/21419581\/?partner=business-vs-crisis_ru&from=bar","icon_class":"glyphicon-shopping-cart"}]
[tv_31_original_source] => 
[tv_32_hide_image] => 
[section_title] => recommended reading
[author_avatar] => /assets/avatars/copy.jpg
[tvs] => Array
(
[sell_link] => Array
(
[tv_id] => 30
[value] => [{"MIGX_id":"1","title":"\u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430 Ozon.ru","link":"http:\/\/www.ozon.ru\/context\/detail\/id\/21419581\/?partner=business-vs-crisis_ru&from=bar","icon_class":"glyphicon-shopping-cart"}]
)

)

[imageDefault] => /uploads/images/No-Photo.jpg
[public_image] => /uploads/lazy/images/65588288e12ab09ae49c8a6f7552e130.jpg
[gallery] => Array
(
)

[sell_link] => Array
(
[0] => Array
(
[MIGX_id] => 1
[title] => Buy Ozon.ru
[link] => http://www.ozon.ru/context/detail/id/21419581/?partner=business-vs-crisis_ru&from=bar
[icon_class] => glyphicon-shopping-cart
)

)

).................


How it looks in the admin interface

In the call in $params you can specify a limit, sort, search terms, etc., etc., In the development process, there is no need to reload the page in the front, to check the result code changes in processor loading. First debugged everything in the admin, and if there's sample is right, then in front will be the same result. The same applies to mechanisms for commenting, publications, feedback forms and all the rest.

Standardization


Standardization built on the basis of Smarty and perfectly friendly terms with processors. For example, here's how you can get an array of news and stuff them in a loop in the resulting HTML:

the
{$params = [
"limit" => 10,
"sort" = > "pagetitle",
"dir" = > "DESC"
]}

{processor action="web/resources/articles/getdata" ns="modxsite" params=$params assign=result}

{if $result.success && $result.object}
{foreach $result.object as $object}
<p>{$object.pagetitle}</p>
{/foreach}
{else}
<div class="alert alert-danger">{$result.message|default:"Record was not received"}</div>
{/if}

Of course this is a simple example (in reality there extensible templates, blocks, include, etc.), but overall the idea of how there about made, gives. And note the similarity of the call in the template and console. Here and there passing it the path to the called processor (in our case it is web/resources/articles/getdata) and is not a required parameter-the array $params.

But perhaps the main advantage of using Smarty is the ability to use multiple design templates (skins). We have the principle that has the base template (supplied with the Assembly), and when the target site is necessary to change the design and/or logic, some kind of change, do not make a complete copy of the skins and fully switch to it, but just pointing out the extra skin, and it's already making changes. This will not only reduce the number of your own skins, but will allow the existing site to roll change Assembly, with new functionality without breaking the current design. Here detailed manual and how to do it. There for example ShopModxBox, but again, the principles in NewsModxBox all the same.

the

Where and how to download



Method 1. Installation on a clean MODX


Attention!!! Do not install this package on the combat website. This is the full site and it will overwrite the current site. Only installs on a clean MODX.

So, the installation process is relatively simple for those who are already working with MODX Revolution. Put a clean MODX. Management then packs add new repository with address http://rest.modxstore.ru/extras/ and shake and install NewsModxBox.

I do Not recommend to install MODX version 2.4.0 and 2.4.1, as there is a very nasty bug, the patch for which has not yet adopted. It is better to put 2.3.6

Method 2. From the archive.


The first way is convenient, but not all hosting sites will be. First, the package weighs in at 50+ meters, where enough memory is allocated, it may not unpack. Secondly, the installation lasts for two seconds, and the installation process can simply be interrupted timeout (and at timeweb.ru when CPU usage is at 100% and after five seconds, the script ends). In this case, for those who are familiar with MODX or just not the first day deals with web designing, suitable option to deploy the site from full dump. Here's a website Packed full with MODX-om, at the root of a dump.sql. All that is required is to unpack it, create the database, fill in the dump and fix up the configs of the site.

Both methods of installation are described in detail in download ShopModxBox (there is even a video).

But for those who can not or do not want to install it yourself Assembly but I want to see it from the inside, there is a third option — to order the installation of the test site. The issue price is 300 rubles, the site will be available for a month. Installs on our hosting and you do not require any unnecessary movements. Form of service order is here.

Content


Filling highlights:

1. In the section Heading add the required sections to the template Section.




2. Now, the keys are available from the news editor. There are articles and create/edit.


Brief pros/cons of the system


Our policy here is the same as with ShopmodxBox — this build just for a quick start. In any case, the final projects will have something to screw the private business processes. We care not about the comprehensive functionality and versatility, and minimize the core, performance and flexibility. That is something between samoriski and CMS. All major projects try for yourself samapika to write that everything worked exactly the way they want. But to write from scratch — makes no sense. Here and their to add not difficult, and all from scratch not have to write.

PS this Friday (02.10.2015) at 19: 00 in our office at the address: Moscow, Novy Arbat, 21, will be held master class on NewsModxBox. Just 6 tickets. If anyone is interested, hurry up.
Article based on information from habrahabr.ru

Комментарии

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

Automatically create Liquibase migrations for PostgreSQL

Vkontakte sync with address book for iPhone. How it was done

What part of the archived web