Blog Sections Open

Why a PHx Condition Can Fail Even When the Placeholder Value Looks Correct

If a placeholder prints the right value but the PHx condition still chooses the wrong branch, the problem is usually in formatting, parsing order, or hidden characters.

A classic PHx debugging trap is this: the placeholder visibly prints 1, but the conditional expression still falls into the else branch. That usually means the runtime value is not exactly what it looks like in the rendered output.

What to check

  • leading or trailing whitespace in the placeholder value
  • string versus numeric comparison behavior
  • the point in the parse chain where the placeholder becomes available
  • whether the placeholder is filled through another modifier first

When in doubt, normalize the value before comparison or move the logic into a small helper snippet where the comparison is explicit and easier to debug.

Newer post

Why getResources Can Keep Outputting Fields from the Current Page Instead of the Requested Resource

How to avoid template-field confusion when getResources is asked to render data from a specific resource.

Older post

Ordering News by the Right Dates When Resources Were Created in Bulk

How to restore meaningful chronology in a news section after many resources were created on the same day.