pods-frontier
pods-frontier copied to clipboard
Calling [if] causes related field data changes
I have a custom taxonomy which is referenced by my custom post type dog as the field registration. The taxonomy name is the dog's registered name.
The taxonomy has the following custom fields:
registration_numbera plain text fieldgendera simple relationship with options "Male" and "Female"sirea self-referential relationship to the taxonomy, filtered by genderdama self-referential relationship to the taxonomy, filtered by gender
I am displaying a dog's page using Pods Frontier Auto Template and the template Dog. I only want to display certain information if it exists, so I installed Pods Frontier in order to get [if][/if] conditionals for my template.
With this template code, everything displays as expected:
<table>
<tr>
<th>Registered Name</th>
<td>{@registration.name}</td>
</tr>
<tr>
<th>Registration #</th>
<td>{@registration.registration_number}</td>
</tr>
<tr>
<th>Gender</th>
<td>{@registration.gender}</td>
</tr>
</table>

However, if I wrap it in [if registration] ... [/if] the related fields get messed up:

It gets even worse if I try to reference {@registration.sire} inside an [if] block, which just results in an empty string.
I'm not sure what you are asking here. I think what you are asking is why [if registration] {@registration.sire} [/if] doesn't work. That's because you're doing what would be the equivalent outside of the if block to {@registration.registration.sire}. Instead do [if registration] {@sire} [/if]
I don't believe that is correct. The context doesn't change inside the [if] block. I tested with this:
[if registration]
<table>
<tr>
<th>Registered Name</th>
<td>{@name}</td>
</tr>
<tr>
<th>Registration #</th>
<td>{@registration_number}</td>
</tr>
<tr>
<th>Gender</th>
<td>{@gender}</td>
</tr>
</table>
[/if]
As expected, {@name} gives me the name of the post NOT {@registration.name} and the other two cells are empty strings because the post doesn't have properties called registration_number or gender.
Moreover [if registration]{@sire}[/if] is still an empty string.
The IF is just a check ams not a context shift. inside it you'll still need to use {@registration.name} and so on.
@Desertsnowman That's why I am reporting this bug.
The display values CHANGE when wrapped inside an [if]...[/if] block. See my screenshot in the first post.