I've got a matrix column with 110 rows but only 11 values (each value in 11 times). Is there a way to query the distinct values in that column rather than returning all the results?
-
1In a front-end template using the Matrix field's tag? or via an SQL query?– Derek HogueFeb 27, 2013 at 0:55
-
Matrix field tag. I can do a manual query, just trying to stay in EE tags if possible.– Ryan ShrumFeb 27, 2013 at 16:18
-
If you know which rows your values sit in you could use the row_id parameter e.g. {my_matrix_field_name row_id="1|2|3"}– erwinheiserFeb 27, 2013 at 23:39
1 Answer
You can't do this with a Matrix tag, but you could use Stash to set a list of the Matrix rows, then get the unique
values only.
https://github.com/croxton/Stash/wiki/%7Bexp%3Astash%3Aget_list%7D#unique---yes--no-
matrix set_list
{exp:channel:entries channel="blog" entry_id="123"}
{exp:stash:set_list name="blog_related_entries" parse_tags="yes" save="yes" scope="site"}
{blog_related}
{stash:item_title}{title}{/stash:item_title}
{/blog_related}
{/exp:stash:set_list}
{/exp:channel:entries}
get_list with unique="yes"
{exp:stash:get_list name="blog_related_entries" unique="yes"}
{item_title}
{/exp:stash:get_list}
Granted, this doesn't really save you on performance since all of the Matrix rows are pulled any way.