I’m trying to create a list of items for a dropdown filter. So after using a series of pdoResources, getImageIists and other snippets to get the finalized output of available data, I have an output that looks something like this: Admission|Second Admission|Admission, 3| and so on (a few hundred results). I specifically divided them by pipes because some results have commas in them.
I then added a snippet to my original pdoResources placeholder like this: [[+listItems:removeDupsList]] to visually check my output for errors.
This resulted in some duplicates being removed, but not all and I cannot figure out why. I even tried using my snippet without any html in it like one article suggested:
It would usually be much better to write a snippet that only returns the data you want. Perhaps someone can help if you give us some more information about how you’re generating the list…
In that last one you’ve got the return statement inside the foreach loop so it returns after the first execution and won’t loop.
Are these duplicates that remain really exactly the same string. array_unique is case sensitive for example or a trailing space can also be a reason why two strings are different.
Thanks but for some reason that still doesn’t work. I’ve checked everywhere, in the MIGX list, the custom DB that it pulls from and just showing the array values in a print_r command. But these spaces keep showing up for no reason.
All I want to do is output a list of items from the MIGX configs list that are currently applied to each of our staff. Just to produce a drop-down list that is used to filter them. I figured outputting a list minus their names would be a reasonable way to do this dynamically and then filter out the duplicates. But for some weird reason these rogue spaces are interfering with that duplication removal.
is this what you wanted? Or something else? I’ve expanded it to 10 people.
Washington DC
FloridaFlorida Southern District Court
Texas
Washington DC
PennsylvaniaNew Jersey
Pennsylvania
Pennsylvania
Washington DCWashington DC District CourtPennsylvania
PennsylvaniaPennsylvania Middle District Court
VirginiaMarylandWashington DCVirginia Eastern District CourtMaryland District CourtWashington DC District CourtNorth Dakota District CourtFourth Circuit Court of AppealsEighth Circuit Court of Appeals
I think i pulled that from the output in the source code.
Here’s what I get with just 3 resources:
District of Columbia|| Florida||U.S. District Court for the Southern District of Florida|| Texas||
I think I figured out what the problem is. The extra space is getting inserted at the end of each record. From this example, there is a space before Florida and Texas, Those are the starts of new records in the getImageList result. Is there a way to fix the record delimiter from this? rather than a space just use || instead?