Creating nested MIGX

Hi All,

I nedd to create a nested Migx so that a user can click add new, and then have the title ( text ), content ( richtext ) and then add mulitple images.

This is so they can add multiple sections to the pages which all have image scrollers but I can’t work out how to get the add new on the images, can anyone point me in the right direction please.

Thanks

1 Like

Create a second MIGX config for the images.

Then in the config (with the “title” and “content” fields) add a new field with “Input TV type” = migx and “Configs” = “name of the second MIGX config”.

Almost there, but when clicking add new on the images I just get a text input and not an image select.

TV hairsparsection
Form Tabs

[{
  "caption": "Info",
  "fields": [{
      "field": "title",
      "caption": "Title"
    },
    {
      "field": "description",
      "caption": "Description",
      "inputTVtype": "text"
    }
  ]
},
{
  "caption": "Image",
  "fields": [{
    "field": "image",
    "caption": "Image 520px by 700px",
    "inputTVtype": "migx",
    "config": "additionalImages"
  }]
}
]

Grid colums

[
  {
    "header": "Title",
    "width": "160",
    "sortable": "true",
    "dataIndex": "title"
  }, {
    "header": "Image",
    "width": "50",
    "sortable": "false",
    "dataIndex": "image",
    "renderer": "this.renderImage"
  }]

TV additionalImages

Form Tabs

[
{
  "caption": "Image",
  "fields": [{
    "field": "image",
    "caption": "Image 520px by 700px",
    "inputTVtype": "image",
  }]
}
]

Grid Colums

[
  {
    "header": "Image",
    "width": "50",
    "sortable": "false",
    "dataIndex": "image",
    "renderer": "this.renderImage"
  }]

What have I done wrong ?

inputTVtype is only correct, if you use a MIGX config (created in the CMP under “Extras” → “MIGX”) for the nested MIGX.

If you use a TV as the nested MIGX, use inputTV = “TV name” instead (and configs is no longer necessary).

Thanks for your time Harry,

Ive updated the hairspasection form tabs to:

[{
  "caption": "Info",
  "fields": [{
      "field": "title",
      "caption": "Title"
    },
    {
      "field": "description",
      "caption": "Description",
      "inputTVtype": "text"
    }
  ]
},
{
  "caption": "Image",
  "fields": [{
    "field": "image",
    "caption": "Image 520px by 700px",
    "inputTV": "additionalImages"
  }]
}
]

But now I get the error “There seems to be an error in the formtabs-config” when I click the add new on the image tab.

Sorry, I’m crap at MIGX it drives me mad :crazy_face:

Sorted, I had a stray , in additionalImages Form Tabs

OK Last question for this, I can’t get the images to display, main template contains:

[[getImageList?
                &tvname=`hairsparsection`
                &tpl=`hairsparsection`]]

hairsparsection chunk contains:

<ul class="hair-spa">
                [[getImageList?
                &tvname=`additionalimages`
                &tpl=`additionalimages`]]
                
            </ul>
            <div class="hair-spa-text">
            <h3>[[+title]]</h3>
                [[+description]]
            </div>

additionalimages chunk contains:

<li class="hair-spa-item">
                    <img src="[[+image]]" alt="Hair-spa" />
                </li>

but nothing is output for the images, what have I done wrong ?

Use the property &value instead of &tvname.

[[getImageList? &value=`[[+image]]` &tpl=`additionalimages`]]

(The data is not actually stored in the TV “additionalimages”. It’s stored as the field “image” in the TV “hairsparsection”.)

Thanks Harry, your a legend :+1:

1 Like

Got another question on this, I’ve created another nested MIgx which has 2 fields
SpaBreaks1

[{
    "caption": "Info",
    "fields": [{
        "field": "title",
        "caption": "Title"
      },{
        "field": "type",
        "caption": "Type"
      },
      {
        "field": "description",
        "caption": "Description",
        "inputTVtype": "richtext"
      },{
        "field": "tag1day",
        "caption": "Tag 1 Days"
      },{
        "field": "tag1price",
        "caption": "Tag 1 Price"
      }
      ,{
        "field": "tag2day",
        "caption": "Tag 2 Days"
      },{
        "field": "tag2price",
        "caption": "Tag 2 Price"
      },{
         "field": "icons",
    "caption": "Icons",
    "inputTV": "icon"
      }
    ]},
  {
    "caption": "Image",
    "fields": [{
      "field": "image",
      "caption": "Image",
      "inputTVtype": "image"
    }]
  }
]

icon has the following

[{
  "caption": "Info",
  "fields": [{
      "field": "title",
      "caption": "Title"
    },{
      "field": "icon",
      "caption": "Icon",
      "inputTVtype": "image"
    }
  ]
}
]

How do I output this ? in the above you said to use &value but theres 2 values with this one, title and icon

In my template I have

<ul>
                            [[getImageList?
                &tvname=`icon`
                &tpl=`iconlist`]]
                        </ul> 

iconlist has the following but nothing is output
<li>[[+icon]][[+title]]</li>

I’ve tried

 [[getImageList?
                &value=`[[+icon]]`
                &tpl=`iconlist`]] 

But that gives errors on the site

The icon tv is also a migx?

if so change the first config like this:

[{
    "caption": "Info",
    "fields": [{
        "field": "title",
        "caption": "Title"
      },{
        "field": "type",
        "caption": "Type"
      },
      {
        "field": "description",
        "caption": "Description",
        "inputTVtype": "richtext"
      },{
        "field": "tag1day",
        "caption": "Tag 1 Days"
      },{
        "field": "tag1price",
        "caption": "Tag 1 Price"
      }
      ,{
        "field": "tag2day",
        "caption": "Tag 2 Days"
      },{
        "field": "tag2price",
        "caption": "Tag 2 Price"
      },{
         "field": "icons",
    "caption": "Icons",
    "inputTVtype": "migx",
    "configs": "icon"
      }
    ]},
  {
    "caption": "Image",
    "fields": [{
      "field": "image",
      "caption": "Image",
      "inputTVtype": "image"
    }]
  }
]

Then in your chunk should work good I think.

in your template you have this then:

<ul>
[[getImageList?
 &value=`[[+icons]]`
 &tpl=`iconlist`
]]
</ul> 

Thanks Dimmy, tried but no cigar I’m afraid

SpaBreaks 1

[{
    "caption": "Info",
    "fields": [{
        "field": "title",
        "caption": "Title"
      },{
        "field": "type",
        "caption": "Type"
      },
      {
        "field": "description",
        "caption": "Description",
        "inputTVtype": "richtext"
      },{
        "field": "tag1day",
        "caption": "Tag 1 Days"
      },{
        "field": "tag1price",
        "caption": "Tag 1 Price"
      }
      ,{
        "field": "tag2day",
        "caption": "Tag 2 Days"
      },{
        "field": "tag2price",
        "caption": "Tag 2 Price"
      },{
         "field": "icons",
    "caption": "Icons",
    "inputTVtype": "migx",
    "configs": "icon"
      }
    ]},
  {
    "caption": "Image",
    "fields": [{
      "field": "image",
      "caption": "Image",
      "inputTVtype": "image"
    }]
  }
]

Template

[[getImageList?
                         &value=`[[+icons]]`
                         &tpl=`iconlist`
                        ]]
                        </ul>

Then on the site I get:

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in 

Ans a list of the errors cache files

did you create the migx with the migx cmp?

/manager/?a=index&namespace=migx&configs=migxconfigs

if so could you export the 2 configs and past them here?
and also show how you created the first tv for your first config?

I never no, Just created them as standard Migx TV’s

SpaBreaks1:

Form Tabs

[{
    "caption": "Info",
    "fields": [{
        "field": "title",
        "caption": "Title"
      },{
        "field": "type",
        "caption": "Type"
      },
      {
        "field": "description",
        "caption": "Description",
        "inputTVtype": "richtext"
      },{
        "field": "tag1day",
        "caption": "Tag 1 Days"
      },{
        "field": "tag1price",
        "caption": "Tag 1 Price"
      }
      ,{
        "field": "tag2day",
        "caption": "Tag 2 Days"
      },{
        "field": "tag2price",
        "caption": "Tag 2 Price"
      },{
         "field": "icons",
    "caption": "Icons",
    "inputTVtype": "migx",
    "configs": "icon"
      }
    ]},
  {
    "caption": "Image",
    "fields": [{
      "field": "image",
      "caption": "Image",
      "inputTVtype": "image"
    }]
  }
]

Grid Columns:

[
  {
    "header": "Content",
    "width": "160",
    "sortable": "true",
    "dataIndex": "content"
  }, {
    "header": "Image",
    "width": "50",
    "sortable": "false",
    "dataIndex": "image",
    "renderer": "this.renderImage"
  }]

icon

Form Tabs

[{
  "caption": "Info",
  "fields": [{
      "field": "title",
      "caption": "Title"
    },{
      "field": "icon",
      "caption": "Icon",
      "inputTVtype": "image"
    }
  ]
}
]

Grid Columns:

[
  {
    "header": "Title",
    "width": "160",
    "sortable": "true",
    "dataIndex": "title"
  }]

Template:

[[getImageList?
                &tvname=`SpaBreaks1`
                &tpl=`spadaypackages`]]

spadaypackages chunk

<ul>
[[getImageList?
 &value=`[[+icons]]`
 &tpl=`iconlist`
]]
</ul> 

iconlist

<li>[[+icon]][[+title]]</li>

Thanks for the help dimmy

when you have:

{
         "field": "icons",
    "caption": "Icons",
    "inputTVtype": "migx",
    "configs": "icon"
      }

you will need a MIGX configuration created in MIGX CMP with name ‘icon’

or have a MIGX TV with name icons (no template assigned!) and have that:

{
    "field": "icons",
    "caption": "Icons",
    "inputTV": "icons"
      }

Ok, here we go:
please go to the migx cmp: /manager/?a=index&namespace=migx&configs=migxconfigs

then klik on add item and enter the name: SpaBreaks and hit save
then right click on that config and klick: Export/Import
then past this code in there, replacing whats in there:

{
  "formtabs":[
    {
      "MIGX_id":12,
      "caption":"Info",
      "print_before_tabs":"0",
      "fields":[
        {
          "field":"title",
          "caption":"Title",
          "pos":1,
          "MIGX_id":50
        },
        {
          "field":"type",
          "caption":"Type",
          "pos":2,
          "MIGX_id":51
        },
        {
          "field":"description",
          "caption":"Description",
          "inputTVtype":"richtext",
          "pos":3,
          "MIGX_id":52
        },
        {
          "field":"tag1day",
          "caption":"Tag 1 Days",
          "pos":4,
          "MIGX_id":53
        },
        {
          "field":"tag1price",
          "caption":"Tag 1 Price",
          "pos":5,
          "MIGX_id":54
        },
        {
          "field":"tag2day",
          "caption":"Tag 2 Days",
          "pos":6,
          "MIGX_id":55
        },
        {
          "field":"tag2price",
          "caption":"Tag 2 Price",
          "pos":7,
          "MIGX_id":56
        },
        {
          "MIGX_id":57,
          "field":"icons",
          "caption":"Icons",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"migx",
          "validation":"",
          "configs":"icon_migx",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":8
        }
      ],
      "pos":1
    },
    {
      "caption":"Image",
      "fields":[
        {
          "field":"image",
          "caption":"Image",
          "inputTVtype":"image",
          "pos":1,
          "MIGX_id":58
        }
      ],
      "pos":2,
      "MIGX_id":13
    }
  ],
  "contextmenus":"",
  "actionbuttons":"",
  "columnbuttons":"",
  "filters":"",
  "extended":{
    "migx_add":"",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "media_source_id":"",
    "multiple_formtabs":"",
    "multiple_formtabs_label":"",
    "multiple_formtabs_field":"",
    "multiple_formtabs_optionstext":"",
    "multiple_formtabs_optionsvalue":"",
    "actionbuttonsperrow":4,
    "winbuttonslist":"",
    "extrahandlers":"",
    "filtersperrow":4,
    "packageName":"",
    "classname":"",
    "task":"",
    "getlistsort":"",
    "getlistsortdir":"",
    "sortconfig":"",
    "gridpagesize":"",
    "use_custom_prefix":"0",
    "prefix":"",
    "grid":"",
    "gridload_mode":1,
    "check_resid":1,
    "check_resid_TV":"",
    "join_alias":"",
    "has_jointable":"yes",
    "getlistwhere":"",
    "joins":"",
    "hooksnippets":"",
    "cmpmaincaption":"",
    "cmptabcaption":"",
    "cmptabdescription":"",
    "cmptabcontroller":"",
    "winbuttons":"",
    "onsubmitsuccess":"",
    "submitparams":""
  },
  "permissions":{
    "apiaccess":"",
    "view":"",
    "list":"",
    "save":"",
    "create":"",
    "remove":"",
    "delete":"",
    "publish":"",
    "unpublish":"",
    "viewdeleted":"",
    "viewunpublished":""
  },
  "fieldpermissions":"",
  "columns":[
    {
      "MIGX_id":1,
      "header":"Content",
      "dataIndex":"description",
      "width":160,
      "sortable":true,
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "header":"Image",
      "width":50,
      "sortable":"false",
      "dataIndex":"image",
      "renderer":"this.renderImage",
      "MIGX_id":2
    }
  ],
  "category":""
}

hit save and close
create another config with the name: icon_migx
save and close

then right click on that config and klick: Export/Import
then past this code in there, replacing whats in there:

{
  "formtabs":[
    {
      "caption":"Info",
      "fields":[
        {
          "field":"title",
          "caption":"Title",
          "pos":1,
          "MIGX_id":59
        },
        {
          "field":"icon",
          "caption":"Icon",
          "inputTVtype":"image",
          "pos":2,
          "MIGX_id":60
        }
      ],
      "pos":1,
      "MIGX_id":14
    }
  ],
  "contextmenus":"",
  "actionbuttons":"",
  "columnbuttons":"",
  "filters":"",
  "extended":{
    "migx_add":"",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "media_source_id":"",
    "multiple_formtabs":"",
    "multiple_formtabs_label":"",
    "multiple_formtabs_field":"",
    "multiple_formtabs_optionstext":"",
    "multiple_formtabs_optionsvalue":"",
    "actionbuttonsperrow":4,
    "winbuttonslist":"",
    "extrahandlers":"",
    "filtersperrow":4,
    "packageName":"",
    "classname":"",
    "task":"",
    "getlistsort":"",
    "getlistsortdir":"",
    "sortconfig":"",
    "gridpagesize":"",
    "use_custom_prefix":"0",
    "prefix":"",
    "grid":"",
    "gridload_mode":1,
    "check_resid":1,
    "check_resid_TV":"",
    "join_alias":"",
    "has_jointable":"yes",
    "getlistwhere":"",
    "joins":"",
    "hooksnippets":"",
    "cmpmaincaption":"",
    "cmptabcaption":"",
    "cmptabdescription":"",
    "cmptabcontroller":"",
    "winbuttons":"",
    "onsubmitsuccess":"",
    "submitparams":""
  },
  "permissions":{
    "apiaccess":"",
    "view":"",
    "list":"",
    "save":"",
    "create":"",
    "remove":"",
    "delete":"",
    "publish":"",
    "unpublish":"",
    "viewdeleted":"",
    "viewunpublished":""
  },
  "fieldpermissions":"",
  "columns":[
    {
      "header":"Title",
      "width":160,
      "sortable":true,
      "dataIndex":"title"
    }
  ],
  "category":""
}

save and close.

in your tv SpaBreaks1, remove all columns and formtabs and put SpaBreaks in configs field and save:

then in your page / template where you like to show your lists paste this:

[[getImageList? &tvname=`SpaBreaks1` &tpl=`spadaypackages`]]

then in your chunk: spadaypackages

<h4>[[+title]]</h4>

<img src="/[[+image]]" width="200"/><br />

<p>[[+description]]</p>

<p>Iconlist:</p>
<ul>
    [[getImageList?
    &value=`[[+icons]]`
    &tpl=`iconlist`
    ]]
</ul> 

<hr/>

You will have this result in your resource:

and in de front end (unstyled in my case):

You should realy try using the cmp, it will give you a lot of freedom.
Hope this helps

ps this is the iconlist chunk:

<li><img src="/static/default/files/[[+icon]]" width="100" /><strong>[[+title]]</strong></li>

i needed this in my test so it would get the proper path,/static/default/files/

Thanks Dimmy, but thats giving the same result as before, I’ve cleared the cache, browser cache, server cache and deleted the cache folder and still no change

@bruno17 I tried that as well and still the same result

what do you get, when you replace the getImageList call just with that placeholder:

[[+icons]]

That seems to work

[{“MIGX_id”:“1”,“title”:“test”,“icon”:“assets/icons/slipper.png”}]

So it’s something in this call that’s breaking it

[[getImageList?
    &value=`[[+icons]]`
    &tpl=`iconlist`
    ]]