Bruno17 / MIGX

MIGX for revo 2.2 and above
83 stars 78 forks source link

Add the path for the photos in renderChunck #372

Open Alexij2 opened 3 years ago

Alexij2 commented 3 years ago

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.

Bruno17 commented 3 years ago

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