Modx revo. How can the gallery plugin be configured to work in multiple contexts?


Hello everyone. There is a site on modx revo , babel is installed, 1 additional context is made.
There is a page on which there is a gallery output, in the case of the default context (web) all the pictures are displayed perfectly, but if you open the translation of the resource in a different context, the photo is not loaded.

As I understand it, it's all about the paths to the files with photos:

  1. here is the path in the web context:

  2. and here is the path in the eng context:


Notice the end of the link:

  1. %2Fassets%2Fgallery%2F3%2F41.jpg

  2. %2Fen%2F%2Fassets%2Fgallery%2F3%2F41.jpg

In en context it signs – %2Fen (or /en)

I want to ask if there is a solution for setting gallery for 2 or more contexts? If there is, how to implement it?


You can of course just add replace:

    <a class="thumb" name="[[+name]]" href="[[+image:replace=`%2Fen%2F==%2F`]]" title="[[+name]]">
        <img src="[[+thumbnail:replace=`%2Fen%2F==%2F`]]" alt="[[+name]]" />


But this is a rough option. I would like everything in my mind)

Here is such a way, you can also use it in the main Gallery snipget line 131… let's go to this:

$itemArray['thumbnail'] = str_replace(array('%2Fen%2F'),'',$item->get('thumbnail',$thumbProperties)); $itemArray['image'] = str_replace(array('%2Fen%2F'),'',$item->get('image',$imageProperties));

In principle, this is the same replay, only already inside the plugin.


$itemArray['thumbnail'] = str_replace(array('%2F'.($modx->context->get('key')).'%2F'),'',$item->get('thumbnail',$thumbProperties)); $itemArray['image'] = str_replace(array('%2F'.($modx->context->get('key')).'%2F'),'',$item->get('image',$imageProperties));

or create a getContextKey snippet

return $modx->context->get('key');

and call in filter

[ [+image:replace= %2F [[getContextKey]]%2F==%2F ]`]

Scroll to Top