📜 ⬆️ ⬇️

MODx. Basic things

Anyone who starts to understand MODx will face new terms. Everything is quite easy to remember. And in order not to have to memorize what and how to spell, we all note here.

Also here we will note the small moments that can periodically be peeped.


')

Terminology


Template - contains a general layout of the page with the structure and design. It also defines places for displaying dynamic content. For each document, you can choose your template.

Parameters (TV) - additional parameters that are connected to the template. Parameters can be of different types (text, link, file, date, number, etc.). For more information about the types, wait in the following articles.

A chunk is a small template that can be used both simply for displaying some content (phone on all pages), and for processing (the template of the eForm letter being sent, the template of the output directory Ditto, etc.). Thus, the type (presentation) of information is separated from the place of processing and is easily managed.

Snippet - code for processing information. Analyze the information received (for example, a user message) and provide the result (for example, send a message by mail, and show the result message to the user). Snippets form the menu (Wayfinder), display lists of articles with pagination (Ditto), build forms (eForm). For withdrawal use Chunks.

A plugin is a code that runs when an event occurs. For example, it highlights the search words (Search Highlighting) when navigating from the search page. There are many events and their consideration is a separate article.

Special tags


To display dynamic data using special tags.

Systemic


[(site_name)] - site name
[(base_url)] or [(site_url)] - site address (http://modx.ru)
[(modx_charset)] - encoding used
[^ qt ^] - time for database queries
[^ q ^] - database queries
[^ p ^] - time to work PHP scripts
[^ t ^] - total time to generate the page
[^ s ^] - content source (base or cache)

Standard


[* pagetitle *] - document title
[* longtitle *] - extended document title
[* description *] - document description
[* introtext *] - document annotation
[* content *] - document content
[* alias *] - document alias
[* id *] - identifier (number) of the document
[* pub_date *] - the date of publication of the document
[* unpub_date *] - publication completion date
[* createdby *] - ID of the user who created the document
[* createdon *] - Document creation date
[* editedby *] - The user ID of the person who edited the document
[* editedon *] - Date of document editing
[~ identifier ~] - URL of the specified document

Additional


[* type *] - option (document, folder or link)
[* contentType *] - content type (for example, text / html)
[* published *] - whether the document is published (1 | 0)
[* parent *] - the number (ID) of the parent document
[* isfolder *] - whether the document is a folder (1 | 0)
[* richtext *] - is the visual editor used when editing a document?
[* template *] - number (ID) of the used template for the document
[* menuindex *] - the number of display in the menu
[* searchable *] - whether the document is searchable (1 | 0)
[* cacheable *] - Whether the document is cached (1 | 0)
[* deleted *] - Document deleted (1 | 0)
[* deletedby *] - ID of the user who deleted the document
[* menutitle *] - The menu title. If not used, the title of the document
[* donthit *] - tracking the number of visits disabled (1 | 0)
[* haskeywords *] - The document contains keywords (1 | 0)
[* hasmetatags *] - The document has meta tags (1 | 0)
[* privateweb *] - The document belongs to a private group of user documents (1 | 0)
[* privatemgr *] - The document is included in the private group of management documents (1 | 0)
[* content_dispo *] - Content delivery option (1 - to display | 0 - to download)
[* hidemenu *] - The document is not displayed in the menu (1 | 0)

TV options, snippets and chunks


[* Name of the TV Parameter *] - displays the value of the parameter in the document.
{{Name Chunk }} - returns the contents of the chunk.
[[Snippet Name]] - returns the result of the snippet. You can also pass additional parameters to the snippet by listing them when you call it - [[Snippet name? & parameter1 = `value1` & parameter2 =` value2` & parameterN = `valueN`]
[+ Variable Name +] - found in chunks that are used for processing (Ditto, eForm, etc.). After processing, values ​​are inserted instead. Thus, this is also a mini-language, but for snippets.

Nuances



1) In fact, there are two options for calling the snippet:
[[Snippet Name]] - cached snippet call
[! Snippet name!] - non-cache snippet call

2) When using additional parameters in the snippet, you need to make sure that the record is not broken by line breaks. If so, then the snippet will refuse to work.

Where to use



Everything is very harmoniously used with each other.
In the templates, you can use the parameters TV, snippets and chunks.
In chunks, you can call snippets, TV parameters and other chunks.
In snippets, you can call everything at all, but through PHP.
Ultimately, you will receive the final result of processing all snippets / chunks / TV parameters.

Sample template



<html>
<head>
<title> [(site_name)] | [* pagetitle *] </ title>
<meta http-equiv = "Content-Type" content = "text / html; charset = [(modx_charset)] "/>
<base href = "[(site_url)]"> </ base>
<link rel = "alternate" type = "application / rss + xml" title = "RSS 2.0" href = "[(site_url)] [~ 11 ~]" />
</ head>
<body>

<div id = "header">
<h1> href="[~[(site_start)~~~""===((site_name)["> [(site_name)] </a> </ h1>
<div id = "ajaxmenu"> [[Wayfinder? startId = `0` & outerTpl =` mh.OuterTpl` & innerTpl = `mh.InnerTpl` & rowTpl =` mh.RowTpl` & innerRowTpl = `mh.InnerRowTpl` & forC. & hereClass = ``]] </ div>
</ div>

<h2> News: </ h2>

[[Ditto? & startID = `2` & summarize =` 2` & total = `20` & commentschunk =` Comments` & tpl = `nl_sidebar` & showarch =` 0` & truncLen = `100` & truncSplit =` 0`]]]

<div id = "content">
<h2> [* longtitle *] </ h2>
[* # content *]
</ div>

</ body>
</ html>


Everything else is based on this information.

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


All Articles