Content Elements | Evolution (Old) | Revolution (New) | |||||
Templates | no tag representation | no tag representation | |||||
Template Variables | [*templatevar*] | [[*templatevar]] | |||||
Chunks | {{chunk }} | [[$chunk]] | |||||
Snippets | [[snippet]] | [[snippet]] | |||||
Plugins | no tag representation | no tag representation | |||||
Modules | no tag representation | does not exist in Revolution | |||||
Content Tags | |||||||
Placeholders | [+placeholder+] | [[+placeholder]] | |||||
Links | [~link~] | [[~link]] | |||||
System Settings | [(system_setting)] | [[++system_setting]] | |||||
Language | no tag representation | [[%language_string_key]] |
Итак, перввым препятствием стало полное отсутствие знакомого до дрожи в коленках Ditto. В качестве замены ему решил использовать снипет getResources. Вызов оного осуществляется так:
[[getResources? ¶m1=`value1`,¶m2=`value2`]]
Параметры следующие:
Параметры для шаблонов
Name | Description | Default Value | Added in version |
---|---|---|---|
tpl | Name of a chunk serving as a resource template. If not provided, properties are dumped to output for each resource | ||
tplOdd | Name of a chunk serving as resource template for resources with an odd idx value (see idx property) | ||
tplFirst | Name of a chunk serving as resource template for the first resource | ||
tplLast | Name of a chunk serving as resource template for the last resource | ||
tpl_N | Name of a chunk serving as resource template for the Nth resource, for example &tpl_4=`tpl4th` | ||
tpl_nN | Name of a chunk serving as resource template for every Nth resource, for example &tpl_n4=`tpl4th` would apply to any item divisible by 4 | 1.4.1 | |
tplCondition | Defines a field of the resource to evaluate against keys defined in the &conditionalTpls property. Must be a resource field; does not work with Template Variables. | 1.5.0 | |
conditionalTpls | A JSON object defining a map of field values and the associated tpl Chunks to use when the field defined by &tplCondition matches the value: &conditionalTpls=`{"1":"tplA","2":"tplB","3":"tplC"}` [NOTE: tplOdd, tplFirst, tplLast, * and tpl_{n} will take precedence over any defined conditionalTpls] | 1.5.0 | |
tplPath | An optional directory to look for file-based chunks when using @FILE | assets_path+ "elements/chunks/" | |
tplWrapper | Name of a chunk serving as a wrapper template for the output [NOTE: Does not work with toSeparatePlaceholders]. The placeholder where the items are inserted is [[+output]]. | 1.6.0 | |
wrapIfEmpty | If true, will output the wrapper specified in &tplWrapper even if the output is empty. | false | 1.6.0 |
outputSeparator | An optional string to separate each tpl instance | "\n" | |
toPlaceholder | If set, will assign the result to this placeholder instead of outputting it directly. | ||
toSeparatePlaceholders | If set, will assign EACH result to a separate placeholder named by this param suffixed with a sequential number (starting from 0). | 1.3.0 |
Name | Description | Default Value | Added in version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
parents | Comma-delimited list of ids serving as parents. Use -1 to ignore parents when specifying resourcesto include. If this is not done, getResources assumes &parents as the current resource and reads its children from there (plus the resources given in &resources = unexpected results). | current Resource id | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
resources | Comma-delimited list of ids to include in the results. Prefix an id with a dash to exclude the resource from the result. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
depth | Integer value indicating depth to search for resources from each parent. First level of resources beneath parent is depth | 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tvFilters | Can be used to filter resources by certain TV values. These are entered as [( tvname)( operator)]( value). There are two delimiters you can use to combine filter conditions.
You can have "OR" filters using two pipe symbols.
An OR filter fetches resources that has one of the listed TV values.
You can also use an "and" filter using a comma.
This will make sure that all the conditions are met.
For advanced filtering you can also group these. It is important
to know that conditions are first separated based on the OR (||) delimiter, and after that on the AND (,) delimiter. So let's take this hypothetical example:
This will filter resources to meet one of the following conditions:
Matches any resources that has an "a" in the mytv value.
Matches any resources that have a mytv value that starts with an "a"
Matches any resources that have a mytv value that ends with an "a".
You can also combine this with the OR (||) and AND (,) delimiters explained above.
It is important to know that this function looks at the raw value
of a template variablefor a specific resource. This means that the value has been explicitly set for the resource, and that it has not been processed by a template variable output type( or is the default value in releases prior to 1.4.2-pl; this release adds support for filtering that includes default values). So if you have an "autotag" tv, this means the raw value is a comma delimited list, and it is not split up in tags like you see it in the manager.
New filter operators available in 1.4.2-pl
Starting with release 1.4.2-pl of getResources, there are a number of new comparison operators for use when creating filter conditions. In addition, when using many of these new operators, numeric comparison values are automatically CAST TV values to numeric before comparison. Here is a list of the valid operators:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sortby | Any Resource Field (excluding Template Variables) to sort by. Some common fields to sort on are publishedon, menuindex, pagetitle etc, but see the Resources documentation for all fields. Specify fields with the name only, not using the tag syntax. Note that when using fields like template, publishedby and the likes for sorting, it will be sorted on the raw values, so the template or user ID, and NOT their names. You can also sort randomly by specifying RAND(), like so:
From version 1.3.0 this can also be a JSON array to sort on multiple fields, e.g.
To sort in a specific order, specify a resource id-list, e.g.
The same thing is possible if you put the sorted IDs in a template variable, like this:
| createdon | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
publishedon | Modified in 1.3.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sortbyAlias | Query alias for sortby field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sortbyEscaped | Escapes the field name specified in sortby | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sortdir | Order which to sort by | DESC | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sortbyTV | Template Variable to sort by | 1.2.0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sortdirTV | Order which to sort by when using sortbyTV | DESC | 1.2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sortbyTVType | Specify the data type of the sortby TV. Possible values are string, integer, decimal, datetime | string | 1.3.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
limit | Limits the number of resources returned. Use `0` for unlimited results. | 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
offset | An offset of resources returned by the criteria to skip | 0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
where | A JSON-style expression of criteria to build any additional where clauses from. See below for an example. Seedisplay/xPDO20/xPDOQuery.where | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
context | Comma-delimited list of context keys to limit results by; if empty, contexts for all specified parents will be used (all contexts if 0 is specified) |
Другие параметры
Name | Description | Default Value | Added in version |
---|---|---|---|
showUnpublished | If true, will also show Resources if they are unpublished. | 0 | |
showDeleted | If true, will also show Resources regardless if they are deleted. | 0 | |
showHidden | If true, will show Resources regardless if they are hidden from the menus. | 0 | |
hideContainers | If set, will not show any Resources marked as a container (is_folder). | 0 | |
includeContent | Indicates if the content of each resource should be returned in the results | 0 | |
includeTVs | Indicates if TemplateVar values should be included in the properties available to each resource template | 0 | |
includeTVList | An optional comma-delimited list of TemplateVar names to include explicitly if includeTVs is 1 | 1.4.0 | |
prepareTVs | Prepares media source-dependant TemplateVar values. | 1 | 1.5.0 |
prepareTVList | Limits the TVs that are prepared to those specified by name in a comma-delimited list | 1.5.0 | |
processTVs | Indicates if TemplateVar values should be rendered as they would on the resource being summarized. TemplateVars must be included (see includeTVs/includeTVList) to be processed. | 0 | |
processTVList | An optional comma-delimited list of TemplateVar names to process explicitly. TemplateVars specified here must be included via includeTVs/includeTVList | 1.4.0 | |
tvPrefix | The prefix for TemplateVar properties | tv. | |
idx | You can define the starting idx of the resources, which is an property that is incremented as each resource is rendered | 1 | |
first | Define the idx which represents the first resource | 1 | |
last | Define the idx which represents the last resource. Default is # of resources being summarized + first - 1 | ||
totalVar | Define the key of a placeholder set by getResources indicating the total number of Resources that would be selectednotconsidering the limitvalue. | total | |
debug | If true, will send the SQL query to the MODX log. | false |
Теперь о плейсхолдерах:
Tag | Data Type | Description | Example Usage |
---|---|---|---|
[[*alias]] | text | Alias | Normally, you will use the id to generate the URL, e.g. Click Here! , but this lets you print out the alias parameter. |
[[*cacheable]] | int 0/1 | Cacheable | |
[[*class_key]] | int | Class Key of the Resource, e.g. modDocument | |
[[*content]] | text | Resource Content | |
[[*content_type]] | int | Content Type | |
[[*createdon]] | date | Created On date, e.g. 2011-04-14 20:40:50, often used in conjunction with the strtotime output filter | [[*createdon:strtotime:date=`%a %b %e, %Y`]] See Date Formats. |
[[*createdby]] | int | Created By User ID Number | |
[[*deleted]] | int 0/1 | Deleted | |
[[*deletedby]] | int | Deleted By User ID Number | |
[[*deletedon]] | date | Date of Deletions | [[*deletedon:strtotime:date=`%a %b %e, %Y`]] See Date Formats. |
[[*description]] | text | Description | |
[[*editedon]] | date | Edited On date, e.g. 2011-04-18 09:06:08 | [[*editedon:strtotime:date=`%a %b %e, %Y`]] See Date Formats. |
[[*editedby]] | int | Edited By User ID number | |
[[*hidemenu]] | int 0/1 | Hide From Menus; this attribute is read by many Snippets, e.g. WayFinder | |
[[*id]] | int | Resource ID | Used frequently to generate links to this page. |
[[*introtext]] | text | Summary | |
[[*isfolder]] | int 0/1 | Container | |
[[*link_attributes]] | text | Link attributes; these are inserted automatically when you use the [[~123]] syntax | |
[[*longtitle]] | text | Long Title | |
[[*menuindex]] | int | Menu Index | |
[[*menutitle]] | text | Menu Title | |
[[*pagetitle]] | text | Page Title | |
[[*parent]] | int | Parent Resource | |
[[*pub_date]] | date ---Publish Date | ||
[[*published]] | int 0/1 | Published | |
[[*publishedby]] | int | Published By User ID Number | |
[[*publishedon]] | date | Published On | [[*publishedon:strtotime:date=`%a %b %e, %Y`]] See Date Formats. |
[[*richtext]] | int 0/1 | Rich Text | |
[[*searchable]] | int 0/1 | Searchable | |
[[*template]] | int | Template ID number | |
[[*unpub_date]] | date – Unpublish Date | [[*unpub_date:strtotime:date=`%a %b %e, %Y`]] See Date Formats. | |
[[*uri_override]] | int 0/1 | Freeze URI | |
[[*uri]] | string | URI |
Итак, начинаю колдовать...
Комментариев нет:
Отправить комментарий