Quote from: Bruno17 at Jan 01, 2013, 03:18 AMuse another fieldname for the annotations-column for example something like
'renderannotations'
Otherwise you will have the rendered output in your annotations-field
Hi Bruno. I've been trying renderChunk just recently, having found a need to have a standard migx inside another. All I want to do is display a thumbnail in the grid for an image TV that has a media source. All is well until I use renderChunk to display the thumb in the grid, and then things start getting weird.
First and most obviously, the Media Source is ignored so renderChunk is necessary so I can hardcode the asset path. A minor inconvenience given that I've used a Media Source to funnel those assets to a specific folder anyway.
Next, I note that you say I should use a different fieldname for the thumbnail column. I've found this to be necessary because if I don't, as I think you've tried to explain, I've found that the chunk is actually altering the data! At one point I tested with a renderChunk with only the word "test" inside. The result was that every time I edited a grid item and clicked "Done" the items in the grid would all be replaced with "test", which was then stored!
I have a question, and a problem. The question is, why would renderChunk have any ability to actually change the source data!? If it didn't, there'd be no need to use a different fieldname, and thus this whole process could be far more intuitive. It really doesn't seem to make sense to have a different fieldname, where previously the fieldname is what is required to hook up the data to the grid column. I read something you said before that seemed to imply there was some advantage to having the renderChunk exert some control over the data, but it seems unwise. Perhaps you could enlighten me. It'd be handy to have a read-only renderChunk so changing fieldnames counterintuitively wouldn't be necessary.
My ultimate problem is that having changed the fieldname and got it more or less working, I find that when using renderChunk, if I add more than one row to my sub-migx data set, something about renderChunk, or the chunk itself, is actually changing/corrupting the json data such that getImageList can no longer process and display it. Rogue output described below suggested a hidden field was being added, something with an "_ro" suffix.
Here's my sub-migx call in the chunk used for the root migx call:
[[!getImageList?
&tvname=`subMigxTV`
&value=`[[+subMigxFieldname]]`
&tpl=`subMigxItemTpl`]]
Once I've added a couple of data rows using renderChunk and saved, the *frontend* output stops appearing, as if [[+subMigxFieldname]] is empty. If I put in an additional reference to [[+subMigxFieldname]] above the getImageList call (so there are two of the same placeholder in the chunk) it then prints out the raw json data within [[+subMigxFieldname]], immediately followed by the correct getImageList output.
[[+subMigxFieldname]]
[[!getImageList?
&tvname=`subMigxTV`
&value=`[[+subMigxFieldname]]`
&tpl=`subMigxItemTpl`]]
Without the preceding [[+subMigxFieldname]] I get nothing at all. I've had similar problems in the past that have turned out to be caching issues, but I'm calling all my snippets uncached. Perhaps I've missed, or misunderstood something. Everything is fine until I add the image field, and associated grid column, using renderChunk with the following chunk, which I've pasted directly into the "renderChunk template" text area. I presume that's correct because it actually works until it starts messing up the source.
[[+image:notempty=`<img src="[[!phpthumbof? &input=`[[+image]]` &options=`w=60&h=60`]]"/>`]]
I get the impression everything would work just fine if I decide to drop the image column from the grid and not bother using renderChunk at all. In order to get things working again I've had to completely remove all the TVs involved. This presumably wipes, or at least ignores all that old data and starts over. I've rebuilt it without the image field and it's all fine so far. I need to work out how to render the image thumbnail in the grid, without altering the source data and without somehow causing this getImageList glitch.
Also, I can corroborate what "thefutureforward" says above, about getting an image TV media source to produce the correct image URL in this scenario. I've had to add &tvname to the getImageList parameters, eventhough I'm using &value and the documentation says &tvname will be ignored.
I have finally given the migx CMP a shot and find it to be excellent, though undocumented it seems. I wonder about the reference to "mediasources" when adding tab fields, and whether it should have some effect on this issue. It'd be nice to iron it out to make it a little easier still to use nested migx objects.
Thanks as ever for all your glorious work with migx. I consider it an integral part of Modx, and echo what others have said about it one day being included in the core.
[ed. note: davidsmith last edited this post 10 years, 6 months ago.]