[migxdb] Description is Code - can I use migxLoopCollection?

Hi All,

Following the discussion of this topic:
https://forums.modx.com/thread/?thread=90099&page=2

I am trying to use the description_is_code with some success:
I was able to successfully use the chunk migx_input_float and by this, include modx placeholder tag on the caption. All went just fine.

But I need to have a caption that gets a field on the same table (not a problem) and then resolve the name of a numeric type field by using migxLoopCollection.

On the same config file I already have this migxLoopCollection call working properly on the table view.
But when copying/pasting on the caption, the title just disappears (even replacing the \n by space). Debug shows nothing, so I am a bit on a dead end.

Did anybody succeed on doing this?

Here is what I am trying to accomplish:

{
  "MIGX_id":2,
  "caption":"Books",
  "print_before_tabs":"0",
  "fields":[
    {
      "MIGX_id":3,
      "field":"Books",
      "caption":"All books for the author [[migxLoopCollection? &packageName=`author` &classname=`Authors` &joins=`[{\"alias\":\"Books\"}]` &where=`{\"id\":\"[[+id]]\"}` &tpl=`@CODE:[[+Books_name]]` &outputSeparator=`` &debug=`0`]] published by [[+editor]]",
      "description":"[[$migx_input_float? &field=`Books`]]",
      "description_is_code":"1",
      "inputTV":"",
      "inputTVtype":"migxdb",
      "configs":"AuthorsBooks",
      "restrictive_condition":"[[MigxCheckIfIsNewItem]]",
      "sourceFrom":"config",
      "sources":"[]",
      "inputOptionValues":"",
      "default":""
    }
  ],
  "pos":2
}

If I omit the migxLoopCollection and include only the [[+author]], no problem seen (but only show the number, obviously).

Many thanks in advance.

what exactly are you trying to show with this call?

Hi Bruno,

Get the author name for this book. The author is stored as Id.
This code I shared above is a tab of authors form having this nested migxdb.

Thanks

Hi Bruno,

I did a different test but this time without migxLoopCollection. I used a different snippet on the caption and worked properly.

This leads me to believe that the problem can be related with the way I am outputting the information from the migxLoopCollection snippet by using @CODE.
Can you give me some hints about “toPlaceholder” option, please?

Thanks again for your valuable help.
Cheers,
JNogueira

OK, I was finally able to understand what causes the problem.

"caption":"All books for the author [[migxLoopCollection? &packageName=`author` &classname=`Authors` &joins=`[{\"alias\":\"Books\"}]` &where=`{\"id\":\"[[+id]]\"}` &tpl=`@CODE:[[+Books_name]]` &outputSeparator=`` &debug=`0`]] published by [[+editor]]",

The problem is related with the join and where arguments where the double quotes are escaped.
I changed the call and added simple arguments with no problem.
But as soon as I escaped the json array with double quotes, it stops outputting the caption.

I will have to scratch my head to find other way to sort this out without using inline migxLoopCollection…

Ok, I was able to solve this moving the migxLoopCollection call to a chunk and passing the needed arguments to the chunk.

Problem solved.
Cheers

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.