CatalogView snippet for MODx Evolution

I Present to you the snippet catalogView. It was created for the new version of Shopkeeper — 1.0 (for MODx Evolution), but now it can be used instead of Ditto.

I did some performance test, both of the snippets. Have 200 documents. Cache snippets is impossible, since it requires pagination. Took about averages after multiple updates of a page.



Challenges snippets:

[!catalogView?
&dataType=`documents`
&tpl=`@FILE:assets/snippets/catalogView/chunks/catalogRow_chunk.tpl`
&parents=`87`
&paginate=`1`
&display=`10`
&sortBy=`pagetitle`
&sortDir=`asc`!]


[!Ditto?
&tpl=`@FILE:assets/snippets/catalogView/chunks/catalogRow_chunk.tpl`
&parents=`87`
&paginate=`1`
&display=`10`
&sortBy=`pagetitle`
&sortDir=`asc`!]


10 documents on the page



catalogView

MySQL: 0.0722 s, 6 request(s), PHP: 0.2756 s, total: 0.3479 s, document retrieved from cache


Ditto

MySQL: 0.1907 s, 32 request(s), PHP: 0.4672 s, total: 0.6579 s, document retrieved from cache


20 documents



catalogView

MySQL: 0.0735 s, 6 request(s), PHP: 0.2934 s, total: 0.3669 s, document retrieved from cache


Ditto

MySQL: 0.2601 s, 52 request(s), PHP: 0.5081 s, total: 0.7683 s, document retrieved from cache


As can be seen, Ditto on every document page, make 2 MySQL query. In the chunk catalogRow_chunk.tpl has one custom PHx modifier, which is used to change the number format price: [+price:num_format+]. If it is clear values will be (20 documents):

catalogView

MySQL: 0.0754 s, 5 request(s), PHP: 0.2794 s, total: 0.3548 s, document retrieved from cache


Ditto

MySQL: 0.2218 s, 32 request(s), PHP: 0.5411 s, total: 0.7629 s, document retrieved from cache


Strangely, the Ditto began to make significantly fewer requests. Each document now on one request. catalogView — less than one General query. I do not know that there is a query and why does PHx, as the code of the modifier is in the file, not in the database, but not important. I was wondering why every PHx-modifier (non-standard) when using Ditto is done in one query in the database, because PHx caches such modifiers.

It was easy. Ditto (2.1.0) does not give PHx the opportunity to cache the modifiers, as in the "rendering" of each document it creates a new object of class PHx ($ditto- > render()). And besides, if you do not use a PHx modifier of the files, one request for every document it too.

catalogView while not very well tested and possible errors. Please report found bugs.

Download catalogView 1.0 RC1

PS of Course, it's time to think about MODx Revo, but I decided to "finish" the Shopkeeper for MODx Evo by releasing the version 1.0 (now beta).
Article based on information from habrahabr.ru

Комментарии

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

The release of the new version of the module modLivestreet 0.3.0-rc

mSearch: search + filter for MODX Revolution

Emulator data from GNSS receiver NMEA