We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37165
    • 89 Posts
    I am using MigxDB (on MODX REV 2.2.13-pl) to create a bunch of custom galleries. I got a lot of help from this post https://forums.modx.com/thread/90198/how-do-i-separate-a-string-of-multiple-values-from-a-tv-in-migxdb-and-wrap-each-one-in-a-chunk-to-make-a-list-of-links#dis-post-495549

    But I am now running into issues using multiple &where calls. Bascially what I am trying to do is assign groups of artworks to multiple resources in migdb. This works fine. I have a column that collects resource ids and is called "exhibition_resource_id and shows them like this:

    9
    or if there are two
    9||12
    or a bunch
    9||12||114||100


    So on each of my resource pages I had the following code:

    					[[!migxLoopCollection?
    					&packageName=`artwork`
    					&classname=`artWorks`
    					&sortConfig=`[{"sortby":"title","sortdir":"ASC"}]`
    					&where=`{"exhibition_resource_id:LIKE":"%[[*id]]%"}`
    					&tpl=`tpl_artist_page`
    					]]	
    


    This worked great until I had over 100 resources. Then what would happen is resource 12 would also pick up items from resource 112 because of the "%" in front of the id.

    So then I tried this:

    				
    	[[!migxLoopCollection?
    					&packageName=`artwork`
    					&classname=`artWorks`
    					&sortConfig=`[{"sortby":"title","sortdir":"ASC"}]`
    					&where=`{"exhibition_resource_id":"[[*id]]", "OR:exhibition_resource_id:LIKE":"%||[[*id]]", "OR:exhibition_resource_id:LIKE":"%||[[*id]]||%", "OR:exhibition_resource_id:LIKE":"[[*id]]||%"}`
    					&tpl=`tpl_artist_page`
    					]]	
    


    This problem here is that instead of the where call looking for 12, ||12, ||12|| and 12||, it only finds 12||

    This happens because it's the last call in my code. If I change the order it only calls whatever is last. But I need it to find the resource not matter what surrounds this. Can someone help?

      • 4172
      • 5,888 Posts
      this is because you have duplicate array-keys in one array

      try this:

      &where=`{"1":[
          {"exhibition_resource_id":"[[*id]]"},
          {"OR:exhibition_resource_id:LIKE":"%||[[*id]]||%"},
          {"OR:exhibition_resource_id:LIKE":"[[*id]]||%"},
          {"OR:exhibition_resource_id:LIKE":"%||[[*id]]"}
      ]}`
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 37165
        • 89 Posts
        Quote from: Bruno17 at Jun 08, 2014, 04:37 PM
        this is because you have duplicate array-keys in one array

        try this:

        &where=`{"1":[
            {"exhibition_resource_id":"[[*id]]"},
            {"OR:exhibition_resource_id:LIKE":"%||[[*id]]||%"},
            {"OR:exhibition_resource_id:LIKE":"[[*id]]||%"},
            {"OR:exhibition_resource_id:LIKE":"%||[[*id]]"}
        ]}`


        perfect, thanks!