Skip to content
  1. Extras
  2. ms2Gallery
  3. Snippets
  4. ms2Gallery

ms2Gallery

Snippet for the resource gallery output.

Parameters

ParameterBy defaultDescription
parentsList of categories for the search of results, with commas. By default the selection is limited by the current parent. If you put 0 there, the selection will not be limited.
resourcesList of resources for output in the results. If a good's id starts with a minus, it will not be shown in the selection.
showLogShow extra information about the work of the snippet. Only for authorized users in "mgr" context.
toPlaceholderIf it is not empty, the snippet will save all data into a placeholder with this name instead of putting them to the screen.
tpltpl.ms2GalleryChunk for the whole gallery using Fenom.
limitLimiting the selection of results
offsetOmission of results from the beginning of the selection
whereA line coded in JSON, with extra searching conditions. For filtration by files you should use the "File" table's pseudonym. For example, &where={"File.name:LIKE":"%img%"}.
filetypeType of files for selection. You can use "image" for indicating pictures and extending all other files. For example: "image,pdf,xls,doc".
showInactiveShow inactive files.
sortbyrankSorting the selection.
sortdirASCThe direction of sorting.
frontend_css[[+cssUrl]]web/default.cssIf you want to use your own styles, show the direction to them here, or clean up the parameter and download them yourself through the site's template.
frontend_js[[+jsUrl]]web/default.jsIf you want to use your own scripts, show the direction to them here, or clean up the parameter and download them yourself through the site's template.
tagsList of tags for files output, with commas.
tagsVarIf this parameter is not empty, the snippet will take "tags" value in $_REQUEST["indicatedname"]. For example, if you indicate "tag" here, the snippet will show only those files that suit in $_REQUEST["tag"].
getTagsMake additional requests so as to get a line with the file's tags?
tagsSeparator,If you switched on getting files' tags in the output, they will be divided through the line that you indicate in this parameter.

Chunks

Before the version 2.0 there were 4 chunks in ms2Gallery:

tplRow - chunk for one element of the selection (tpl.ms2Gallery.row). tplOuter - the outer part of the output of the results of the snippet's work (tpl.ms2Gallery.outer). tplEmpty - chunk that is shown if there are no results (tpl.ms2Gallery.empty). tplSingle - chunk that is used if there is only one file in the results.

Now it is the one and only tpl, which gets the $files array and has to sort it out by itself:

fenom
{if count($files) > 1}
  <!-- there are many files - we sort them out in cycle-->
  {foreach $files as $file}
    <a href="{$file.url}"><img src="{$file.small}"></a>
  {/foreach}
{elseif count($files) == 1}
  <!--there is only one picture, we print the whole data array-->
  {$file | print}
{else}
  There are no files, we shown this caption.
{/if}

All previews generated for files are turned on automatically under their pseudonyms.

If you do not want to switch to the new format, just indicate your old chunks and an empty &tpl:

modx
[[!ms2Gallery?
  &tplRow=`tpl.ms2Gallery.row`
  &tplOuter=`tpl.ms2Gallery.outer`
  &tplEmpty=`tpl.ms2Gallery.empty`
  &tplSingle=`tpl.ms2Gallery.single`
  &tpl=``
]]

Although it is definitely better to rewrite them to Fenom. You will work more comfortably and change them faster.

Scripts and styles

Scripts and styles that you add are indicated by parameters frontend_css and frontend_js. By default they have a simple interface, and the basic picture can be changed by a click (for old chunks, before the 2.0 version).

For a new chunk of the 2.0 version there is also Fotorama if the picture container has class="fotorama". You can set it according to the documentation through data- attributes.

If you do not going to need scripts and styles, you can just leave these parameters empty:

modx
[[!ms2Gallery?
  &frontend_css=``
  &frontend_js=``
]]

Examples

Output of the gallery of the current resource's files

modx
[[!ms2Gallery]]

Output of pictures from different resources in one gallery

modx
[[!ms2Gallery?
  &parents=`0`
  &resources=`5,16,7`
]]