MIGX icon indicating copy to clipboard operation
MIGX copied to clipboard

Add the path for the photos in renderChunck

Open Alexij2 opened this issue 4 years ago • 1 comments

Hello! I suggest adding the ability to correctly render photos via renderChunck. To do this, you need to set the placeholder of the path for the photo in this chunk field, taking into account the source from TV. I offer an example of a solution here. If what I suggest can be solved in a different way, great.

For example render chunk here http://joxi.ru/p279MNzUKqQZgr

https://github.com/Bruno17/MIGX/blob/1e8ad29f69fbd0d11231129a4d45d77f590a6869/core/components/migx/model/migx/migx.class.php#L1621 And the code for setting the tvsourcepath.

// add the path by the photos for renderChunck
        if($properties['_request']['tv_name']){
            $restv = $this->modx->getObject('modTemplateVar',['name' => $properties['_request']['tv_name']]);
            $sore = $restv->get('source');
            if ($sore != 0){
                $this->source = $this->modx->getObject('modMediaSource', $sore);
            }
        }
        if($this->source){
            $soura = $this->source->toArray();
            $pathimgs = trim($soura['properties']['basePath']['value']); // путь
            $mypars = $this->modx->getParser();
            $mypars->processElementTags('',$pathimgs,true, true, '[[', ']]', [], 5);
            unset($mypars);
            $pathimgs = '/'.$pathimgs;
            $properties['tvsourcepath'] = $pathimgs; // magic placeholder
        }

Past it in metod renderChunk от migx.class.php in line 1621 before parse.

Alexij2 avatar May 18 '21 14:05 Alexij2

that's not the right place to add this functionality. renderChunk could be called from elsewhere. So, all needed properties should be passed from outside into the renderChunk - method

Bruno17 avatar May 18 '21 17:05 Bruno17