Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complicated grid-relationship-grid parsing issue. #2615

Open
robinsowell opened this issue Dec 7, 2022 · 6 comments
Open

Complicated grid-relationship-grid parsing issue. #2615

robinsowell opened this issue Dec 7, 2022 · 6 comments
Assignees
Labels
Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on.

Comments

@robinsowell
Copy link
Contributor

robinsowell commented Dec 7, 2022

Have an entry with a grid field. One of the columns is a relationship.

The related entry has a grid field with a text field and an image field.

This works:

{exp:channel:entries channel="pages" entry_id="1"}
        
{main_grid}

  <h2>block {main_grid:row_id} {main_grid:title}</h2>
  
{main_grid:sliderrel}		

related slider entry title:{main_grid:sliderrel:title}<br><br>
slider images: 
 {main_grid:sliderrel:slider}
 slider image title: {main_grid:sliderrel:slider:title}<br>
  {main_grid:sliderrel:slider:image}
      URL: {url}<br>
  {/main_grid:sliderrel:slider:image}
{/main_grid:sliderrel:slider}
{/main_grid:sliderrel}

{/main_grid}

<hr>
 more stuff

{/exp:channel:entries}'

If you use the main_grid tag more than once? It does not work, only the first one shows anything and the rest is blank. Template code:

{exp:channel:entries channel="pages" entry_id="1"}
        
             {main_grid row_id="5"}

   <h2>block id 5 {main_grid:title}</h2>
  
 {main_grid:sliderrel}		

 related slider entry title:{main_grid:sliderrel:title}<br><br>
 slider images: 
  {main_grid:sliderrel:slider}
  slider image title: {main_grid:sliderrel:slider:title}<br>
   {main_grid:sliderrel:slider:image}
       URL: {url}<br>
   {/main_grid:sliderrel:slider:image}
 {/main_grid:sliderrel:slider}
 {/main_grid:sliderrel}

 {if main_grid:buttons != ""}
 block buttons:<br>
 {main_grid:buttons}
 {/if}

 {/main_grid} 

            
 {main_grid row_id="1"}
 <h2>block id 1 {main_grid:title}</h2>            			
      {main_grid:image} -{main_grid:title}
 {/main_grid} 
           
 {main_grid row_id="2"}
  <h2>block id 2 {main_grid:title}</h2>
 {/main_grid}

 {main_grid row_id="3"}
 {/main_grid}


 {main_grid}ALL main_grid id/title: {main_grid:row_id} -- {main_grid:title}<br />{/main_grid}

 <hr>
 more stuff

 {/exp:channel:entries}
@robinsowell robinsowell added the Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on. label Dec 7, 2022
@intoeetive
Copy link
Contributor

This might (or might not) be related to #1036 and #787

@intoeetive
Copy link
Contributor

This is related to the fact that Grid field is taking entry_id based on $this->row object that is set by channel parser. So when Grid in related entry is parser, the entry_id is reset. And then when original entry's Grid is about to be parsed, the row cannot be found, because wrong entry_id is passed.

I think we need to either:

  • not use $this->row in Grid field at all but have another way to pass entry ID
  • reset the $this->row after Relationship parser finishes its work (and preferrably without making Channel Entries parser go through whole process again)

So far, I wasn't able to figure out how to do any of those. Maybe there's another more simple solution, so I need someone else to have a look.

@shbchk
Copy link

shbchk commented Feb 27, 2024

I'm wondering if there any news about this?

I am experiencing issue with grids where adding one more grid call breaks totally different grid. It's frustrating!

@intoeetive
Copy link
Contributor

I believe we did not look into in since when the last comment was made. @bryannielsen perhaps you could spend couple of hours investigating this at some point

@shbchk
Copy link

shbchk commented Mar 14, 2024

Wow, now it's even not a grid call. I am adding just one more {field} in a template - and one of my grids is breaking.

So, I decided to take a closer look why this exact grid call is breaking and not any others. So, here is the code:

{if "{film_filmmakers_grid:total_rows search:film_filmmaker_production_role='Director'}" <= 2}
  {film_filmmakers_grid search:film_filmmaker_production_role='Director' backspace='2'}
      {film_filmmakers_grid:film_filmmaker_relationship:filmmaker_en_name:trim}, {/film_filmmakers_grid}
{if:else}
  {film_filmmakers_grid search:film_filmmaker_production_role='Director' limit='1'}
    {film_filmmakers_grid:film_filmmaker_relationship:filmmaker_en_name:trim} and {exp:mx_calc expression="{film_filmmakers_grid:field_total_rows}-1"} others
  {/film_filmmakers_grid}
{/if}

It looks like this part is problematic:

{film_filmmakers_grid:total_rows search:film_filmmaker_production_role='Director'}

When I remove the search part of it search:film_filmmaker_production_role='Director', it stops breaking.

@shbchk
Copy link

shbchk commented Mar 14, 2024

By "breaking" I mean this:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Accepted Bug has been confirmed, is reproducible, and ready to work on.
Projects
None yet
Development

No branches or pull requests

4 participants