I have a grid field like this:

File - Text field - Relationship field

Where the file is a document, the text field is the title and the relationship field is the argument.

I would like to output the list of files like this:

Argument 1

  • File 1
  • File 2
  • File 3

Argument 2

  • File 4
  • File 5
  • File 6

And so on, therefore grouped by the relationship field.

Now I have something like


<li><a href="{grid:file}"> {grid:text_field} </a> - {grid:relationship}{grid:relationship:title}{/grid:relationship}</li>


That shows me:

  • File 1 - Argument 1
  • File 2 - Argument 1
  • File 3 - Argument 1
  • File 4 - Argument 2
  • File 5 - Argument 2
  • File 6 - Argument 2

How can I output the items by grouping them by argument? It means that the relationship field must shows only one time per type, and create a list for every type.

4 Answers 4


I'm just thinking here, but if you install Stash and use something like the following. This code is not tested and not sure get_list can be nested but the theory should be sound :)

{exp:channel:entries url_title="{segment_2}"}
{exp:stash:set_list name="entries" parse_tags="yes"} //Grab all your entries

{exp:stash:set_list name="group_titles" unique="yes" trim="yes"} //Grab just the titles in a seperate list

{exp:stash:get_list name="group_titles" prefix="outer"} //Grab the list of titles
    {exp:stash:get_list name="entries" match="#{outer:group}#" against="related" prefix="inner"} //Grab the entries and match them against the current group
    <li>{inner:title} / {inner:file} / {inner:group}</li>

I resolved using Matrix and Playa. I used those because of the Playa parents tag. I could not use the native features of Grid and Relationship because, according to the documentation, “Currently it is not possible to get the parents of a relationship field that is inside of a Grid field”.

The code is:

{exp:channel:entries channel="arguments"}
  {exp:playa:parents channel="documents" var_prefix="doc"}
   {doc:matrix_field search:relationship="[{entry_id}]"}
    <li><a href="{file}">{text_field}</a></li>

I did a similar thing with matrix field and in a low variables field. Thanks to @stuartmcd69 - I simplified his a bit.

{exp:stash:set_list name="groups" parse_tags="yes" unique="yes" }
  {exp:low_variables:parse var="report_downloads" order_by="category"}

then further in the template the output

{exp:stash:get_list name="groups" unique="yes" trim="yes"}
  {exp:stash:embed name="downloads" stash:category="{group}"}

and the embed template looks like

{exp:low_variables:parse var="report_downloads" search:category="={stash:category}"}
    <a href="{file}">{title}</a>

Stephen T actually had a wonderful answer, maybe you try this:

{exp:channel:entries channel="zones"}
    {parents field="zone_relationship_field" channel="club_listing"}

See this link Grouping entries by relationship field (title)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.