Hey,
can anyone tell me how to use inheritance with the migx TV?
I use migx to save multiple pictures for a slideshow in the page header. I tried to use @INHERIT as default value, but the migx TV doesn't use it...
Thanks,
Martin
-
☆ A M B ☆
- 24,524 Posts
You can use another Textarea type TV with something like this as its default
<ul>
[[!getImageList?
&docid=`1`
&tvname=`Images`
&tpl=`@CODE:<li>[[+idx]]<img src="[[+image]]"/><p>[[+title]]</p></li>
`]]
</ul>
Note the &docid property.
Hi,
works like a charm...I combined it with the "UltimateParent" as docid. Still this approach is not very enduser-friendly. I think about using a dropdown to select the resource from which to inherit the code. Here I could also use a fix default value or the UltimateParent again.
It would be nice if it was possible just to use @INHERIT....
But thanks a lot....It's a good solution for now...
-
☆ A M B ☆
- 24,524 Posts
MIGx TVs aren't like other TVs. They have their output displayed by snippet, not automatically as standard MODx TVs do. The MIGx TV data is stored as a JSON string, so it has to be unpacked and run through a tpl. I don't see how that could be dealt with using @INHERIT.
Maybe it's possible to check the parents JSON string, if the JSON string is of the resource is empty and the default value is set to @INHERIT. I suppose this should be done in the snippet which computes the output.
The workaround works fine, but it's not the best thing for the users....If I find some time I'll have a deeper look at it!
Does it work this way, when having default-value: @INHERIT ?
<ul>
[[!getImageList?
&tvname=`Images`
&value=`[[*Images]]`
&tpl=`yourTpl`
`]]
</ul>
I had issue with that too... remember you can use @SELECT:
If I want to set default values for example from document 1, and my migx template variable is id 27, I'll put this in the default value field:
@SELECT `value` FROM `modx_site_tmplvar_contentvalues` WHERE `tmplvarid`='27' AND `contentid`='1'
Note that ofc this doesn't really INHERIT, as it's from a specific ressource id.
just wanted to say thanks alain-hki, your solution is perfect for my situation!