Bruno17 / MIGX

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

Incorrect file source for images in MIGX-grid inside another MIGX-grid #434

Open Ruslan-Aleev opened 2 months ago

Ruslan-Aleev commented 2 months ago

1) I create a TV for the image (standard TV image in MODX), set the file source for the TV, and specify the TV in the MIGX Form Tabs via the inputTV for the MIGX-TV grid.

migx_source_1

2) Then I set this MIGX-TV through inputTV in another MIGX-TV grid.

migx_source_2

3) So, image previews ("renderer": "this.renderImage") when adding/editing an element are not displayed correctly. This happens because the file source is set to standard (from the system settings), and not the TV source (this can be seen by viewing the element code).

migx_source_3

Probably some of the functions are not working correctly.

https://github.com/Bruno17/MIGX/blob/master/core/components/migx/model/migx/migx.class.php#L1695

https://github.com/Bruno17/MIGX/blob/master/core/components/migx/model/migx/migx.class.php#L1707

Bruno17 commented 1 month ago

did you try to debug, what happens in getFieldSource?

Ruslan-Aleev commented 1 month ago

I tried debug, but I didn't quite understand the logic. getFieldSource returns $mediasource = $this->getDefaultSource() it seems. Maybe the problem in prepareSourceForGrid($inputTv) in the line $tv = $this->modx->newObject('modTemplateVar') I tried watching ID TV and sources and the last TV didn't have ID.

halftrainedharry commented 1 month ago

Is there a reason why you use an image TV "slider_src" and not just "inputTVtype":"image"?


Maybe try using the setting "sourceFrom". It kind of seems to work if I use "sourceFrom": "migx" in "about_slider_items" and "sourceFrom": "tv" in "about_slider" and set the correct media-source in the TV "about_slider_items".

about_slider_items

[{
    "caption": "Слайдер",
    "fields": [{
        "field": "image",
        "caption": "Изображение",
        "inputTV": "slider_src",
        "sourceFrom": "migx"
    }]
}]

about_slider

{
    "field": "items",
    "caption": "Изображения",
    "inputTV": "about_slider_items",
    "sourceFrom": "tv"
}

Also, have you tried using MIGX configurations (menu "Extras" ("Пакеты") -> "MIGX" ->tab "MIGX") instead of putting all the settings directly into TVs?

Ruslan-Aleev commented 1 month ago

Is there a reason why you use an image TV "slider_src" and not just "inputTVtype":"image"?

I'm using inputTV to set the media source. There is probably another option, but this one is more familiar to me, and it works reliably.

Maybe try using the setting "sourceFrom".

Yes, this works, thanks. I solved this using renderChunk, where I set the id media source:

[{
"dataIndex": "image",
"header": "Изображение",
"sortable": "false",
"renderer": "this.renderChunk",
"renderchunktpl": "<img src='/promtConnectors/system/phpthumb.php?h=80&f=png&src=[[+image]]&source=4'>",
"width": "900"
}]

Also, have you tried using MIGX configurations (menu "Extras" ("Пакеты") -> "MIGX" ->tab "MIGX") instead of putting all the settings directly into TVs?

For this task it is unnecessary, as it seems to me, MIGX configuration takes a lot of time.

I understand that the problem can be solved in different ways, BUT the fact that the current option works a little incorrectly is 100%.