ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Relationships within Grid

August 30, 2013 11:43am

Subscribe [3]
  • #1 / Aug 30, 2013 11:43am

    Shoot the Moon

    2 posts

    Hi there!

    I have two Relationship fields within a Grid field.  What tag syntax do I use to get an output?

    I’ve tried:

    {exp:channel:entries channel="projects" disable="categories|member_data|pagination"}
              <ul>
                  {ticket_assignments} <!-- Grid field name -->
                      {ticket_assignments:gd_assign_to_client_rel:title} <!-- 'gd_assign_to_client_rel' is the first Relationship field -->
                  {/ticket_assignments}
                <li>
                  <ul>
                    <li>{title}</li>
                    <li>{job_number}</li>
                  {ticket_assignments}
                    <li>
                      {ticket_assignments:gd_existing_tickets_rel:title} <!-- 'gd_existing_tickets_rel' is the second Relationship field -->
                   </li>
                  {/ticket_assignments}
                  </ul>
                </li>
              </ul>
    {/exp:channel:entries}


    This actually seems to work but I get errors… (see below)

    Nothing is output from the second Relationship field at all.  I’ve checked the entry and I have indeed allocated items.

    Errors are:

    Severity: Notice
    Message: Undefined offset: 5
    Filename: libraries/Grid_parser.php
    Line Number: 155


    and also…

    Severity: Warning
    Message: Cannot modify header information - headers already sent by (output started at /file/path/to/my/website/system/codeigniter/system/core/Exceptions.php:170)
    Filename: core/Common.php
    Line Number: 412

    I hope this makes sense?

    Many thanks

  • #2 / Aug 31, 2013 11:58am

    Rob Allen

    3105 posts

    Try something like this:

    {ticket_assignments}
        {gd_assign_to_client_rel}
            {title} 
        {/gd_assign_to_client_rel}
    {/ticket_assignments}
  • #3 / Sep 02, 2013 4:35am

    Shoot the Moon

    2 posts

    Hi Rob,
    Thanks for the response.  I gave that a go but it just gave me the title of the project - hence it just ignored the {ticket_assignments} and {gd_assign_to_client_rel} tags.

    In my code the first set of tags does what I want…

    {ticket_assignments}
    {ticket_assignments:gd_assign_to_client_rel:title}
    {/ticket_assignments}

    ...it’s the second set that fail but the structure seems to be the same??

    Regards

    Martin

  • #4 / Nov 05, 2013 11:16am

    100hertz

    8 posts

    I use the ‘Taxonomy’ solution to tackel the relationship/grid issue.

    {exp:channel:entries channel="mychannelname" dynamic="on"}
    {embed="includes/my-relationship-content" thechannel="mychannelname" the-entryid='{relationships_new}{relationships_new:entry_id}|{/relationships_new}'}
    {/exp:channel:entries}

    then put this in your embed

    {exp:channel:entries channel="{embed:thechannel}" entry_id="{embed:the-entryid}" dynamic="no"}
    {mygridfield}
    {mygridfield:image}
    {mygridfield:imagecaption}
    {/mygridfield}
    {/exp:channel:entries}

    What if you want to list multiple relationships with grid fields in the correct order?
    Get a list of entry-id’s to parse to an embed;

    {embed="includes/my-relationship-content" thechannel="mychannelname" entry_ids='{exp:channel:entries channel="mychannelname" dynamic="off"}{relationships_new}{relationships_new:entry_id}|{/relationships_new}{/exp:channel:entries}'}

    entry_ids is now something like “1|2|3|4”

    use this in the ‘my-relationship-content’ template with the fixed_order tag, like this;

    {exp:channel:entries channel="{embed:thechannel}" fixed_order="{embed:entry_ids}" dynamic="no"}
    {mygridfield}
    {mygridfield:image}
    {mygridfield:imagecaption}
    {/mygridfield}
    {/exp:channel:entries}


    a bit sloppy, but works like a charm.

     

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases