ZoomX. Changing the rules of templating in MODX Revolution

Hello friends! Good news for modders - a component that we've talked about a lot in the community has come out. Perhaps not everyone knows what it is about. Let me tell you more.



What is ZoomX



The task that this component allows to solve is the maximum complete rejection of the built-in MODX template engine. Thus, we throw away multiple content parsing, elements stored in the database, placeholders with dots and pluses, and add any modern fast powerful PHP template engine. Standard templates from the database are now used only to bind TV-sheks to resources.



Smarty is immediately available out of the box, since it is already present in the kernel. Plus, through the extension capabilities built into the system, the request processing class and the response preparation class have been replaced. No need to shake or stir, as is the case with Fenom. After installing the component, you can create templates in a convenient IDE editor without going into the admin panel. The only thing left to do is to link them to resources. And for this, Nikita Popov's FastRoute is used .



Router



MODX Revolution has several components that allow you to control routing. But they all fire on the OnPageNotFound event , i.e. when MODX did not find the document at the specified URI. In ZoomX, routing is triggered before inline document search. And the result depends on the mode:



  • Disabled. All specified routes are ignored. MODX works normally.
  • Joint (soft). If no route is found for the specified URI, MODX will continue processing the request as usual.
  • Strict. If no route is found for the specified URI, then processing the request will be completed with a 404 error.


Thus, you can work either in the usual mode, or use the PHP template engine only for the specified resources, or completely surrender control to the PHP template engine. It's up to you.



When using the PHP template engine (at the first stage it is Smarty), the standard MODX syntax will also be available. There is a special parse tag for this :



{parse}
[[!snippet?foo=`bar`]]
{/parse}
//  
{'[[!snippet?foo=`bar`]]'|parse:'modParser'}


ZoomX also adds additional Smarty plugins to work with MODX.



In short, that's all. You can read more in the documentation . In the near future we plan to add the Blade template engine to the list of available templates.



Project on GitHub .



All Articles