MIGX getImageList using placeholder in the WHERE parameter

Is it a syntax issue that I am having?

    &where=`{"url:=":"[[+My_Link]]"}`
    &where=`{"url:=":[[+My_Link]]}`
[[getImageList?
   &tvname=`LinkList`
   &tpl=`@CODE:Load resource id <strong>[[+resource]]</strong>`
   &where=`{"url:=":[[+My_Link]]}`
   &docid=`2996`
 ]]

I was trying to avoid creating a one-off snippet.

I think this should work.

You probably have to use the version with the quotes (&where=`{"url:=":"[[+My_Link]]"}` ) to get valid JSON.

So what is the value of the placeholder [[+My_Link]] and how is it set?

I am using FastField.

[[!#SERVER.HTTP_REFERER:toPlaceholder=`My_Link`]]

[[!+My_Link]]

  [[getImageList?
    &tvname=`LinkList`
    &tpl=`@CODE:Load resource id <strong>[[+resource]]</strong>`
    &where=`{"url:=":"[[!+My_Link]]"}`
    &docid=`2996`
  ]]

if the placeholder is uncached, then you have to call getImageList uncached as well.

[[!getImageList?
    ...
]]

I tried both, I was hoping that the placeholder would get “set” first before it was being evaluated by getImageList

It did a test and [[!#SERVER.HTTP_REFERER:toPlaceholder=`My_Link`]] converted an ampersand (&) in the url to &amp;, so the string comparison in the filtering didn’t work.

1 Like

I would be interested in knowing how you tested. I tried viewing source vs. rendered it I guess the browser was “fixing” it for me.

This will fix it, but not for everything.

&where=`{"url:=":"[[!+My_Link:replace=`&amp;==&`]]"}`

FYI, FastField hasn’t been updated for 8 years according to SiteDash. IIRC, it modifies the MODX parser, so it may not work in your version, and updates to MODX may disable it. I think it’s unlikely that it will work as is in MODX 3.

I think a one-line snippet might be in order. Something like (untested):

$modx->setPlaceholder('My_Link', $_SERVER['HTTP_REFERER']);
return '';

You could also bypass the setPlaceholder call by creating a snippet called GetReferer, and do this:

[[getImageList?
    &tvname=`LinkList`
    &tpl=`@CODE:Load resource id <strong>[[+resource]]</strong>`
    &where=`{"url:=":"[[!GetReferer]]"}`
    &docid=`2996`
  ]]
/* Get Referer snippet */
return $_SERVER['HTTP_REFERER'];
1 Like

Technically I am using pdotools.

I may end up eventually doing what you proposed. I just hate having to use single use snippets if I have to.

I get that. I do it all the time since they’re almost always faster than the alternatives, but your needs may be different from mine.

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”.