Question:
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:
-
here is the path in the
web
context:/assets/components/gallery/connector.php?action=web/phpthumb&ctx=web&w=57&h=57&zc=1&far=C&q=90&src=%2Fassets%2Fgallery%2F3%2F41.jpg
-
and here is the path in the
eng
context:/assets/components/gallery/connector.php?action=web/phpthumb&ctx=eng&w=57&h=57&zc=1&far=C&q=90&src=%2Fen%2F%2Fassets%2Fgallery%2F3%2F41.jpg
Notice the end of the link:
-
%2Fassets%2Fgallery%2F3%2F41.jpg
-
%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?
Update
You can of course just add replace:
<li>
<a class="thumb" name="[[+name]]" href="[[+image:replace=`%2Fen%2F==%2F`]]" title="[[+name]]">
<img src="[[+thumbnail:replace=`%2Fen%2F==%2F`]]" alt="[[+name]]" />
</a>
</li>
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.
Answer:
$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
]`]