MODX - Access TV's of resource fetched from a ResourceList and display with getImageList

1k Views Asked by At

I'm trying to output template variables from resources input into a MIGX template variable, which references a template variable with an input type of 'Resource List'. Is this possible?

I've got a template variable(TV) in MODX which has an input type of "Resource List", this TV is called 'product_offer'. This resource list has a where clause which states that it can only contain products with a certain template ID.

I then have another TV which has an input type of MIGX. I use this TV to allow one of my resources to select a list of Resources in a template variable. The MIGX TV's form tab JSON is below. This TV is called 'offersList'.

[
{"caption":"Product", "fields": [
    {"field":"Product","caption":"Product","inputTV":"product_offer"}
]}
] 

In one of my chunks i'm using getImageList (snippet that comes with migx) to display the list of resources that I've input into the 'offers_list'. Code snippet below:

[[getImageList? 
    &tvname=`offersList`
    &tpl=`StoreCategoryTpl-New`
]]

The chunk "StoreCategoryTpl-New" accesses the resources with this specific ID's template variables and displays a number of them. A cut-down snippet of the chunk is below.

<div class="product-container">        
        <img src="[[+tv.productImage:phpthumbof=`w=150&h=150&zc=1`]]" alt="Thumb of ([[!getResourceField? &id=`[[+product]]` &field=`pagetitle`]])" />
        <h3>[[+pagetitle]]</h3>
</div>

Everywhere else in the site I have used this chunk to output the result of a getResources call, getResources of course can output Template Variables.

Can I access the template variables from the resources I've selected in my 'offersList' MIGX TV and output them in the chunk? I can't find any material for this on the forum or through Google searching.

If not, is the only solution to do this with getResources, and perhaps make a new TV which allows the user to enter in multiple Resource ID's as the value, then feed that into the getResources call (to only get those resources)?

1

There are 1 best solutions below

0
On

I can only guess, but did you try and set the input TV Type like mentioned here? https://docs.modx.com/extras/revo/migx/migx.backend-usage

I'd try and set the TV type.

Anyway, in the output chunk, you are trying to access the TVs like you would do with pdoTools or getResources before. As you would have to set "includeTVs", I guess it is not the default behaviour to read the TVs values from the database.

Yout Attempt to read them with getResourceField instead should work, also with the tv.productImage.

One last thing: you're using phpthumbof. Try pthumb instead, it is the new version and you can use it just like phpthumbof before.