pods-frontier icon indicating copy to clipboard operation
pods-frontier copied to clipboard

Calling [if] causes related field data changes

Open PoetikDragon opened this issue 10 years ago • 4 comments

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_number a plain text field
  • gender a simple relationship with options "Male" and "Female"
  • sire a self-referential relationship to the taxonomy, filtered by gender
  • dam a 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>

image

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

It gets even worse if I try to reference {@registration.sire} inside an [if] block, which just results in an empty string.

PoetikDragon avatar Apr 01 '15 23:04 PoetikDragon

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]

Shelob9 avatar Apr 03 '15 00:04 Shelob9

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.

PoetikDragon avatar Apr 04 '15 01:04 PoetikDragon

The IF is just a check ams not a context shift. inside it you'll still need to use {@registration.name} and so on.

DavidCramer avatar Apr 04 '15 05:04 DavidCramer

@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.

PoetikDragon avatar May 06 '15 21:05 PoetikDragon