• Resolved prccn

    (@prccn)


    Recently, I’m facing a problem when using Polylang in the Pods template. Here is my code:

    [if my_field_name] label_name: {@my_field_name} [/if]

    I am trying to use the Polylang plugin to replace label_name with <?php pll_e('label_name'); ?>, but it is not working. Could you advise me on how to proceed?

Viewing 1 replies (of 1 total)
  • Plugin Support Paul Clark

    (@pdclark)

    The value of a Pods field annotated in magic tags can be ran through helper functions by separating the field name and helper function with a comma, like {@my_field_name,pll_e} —?as long as `function pll_e() takes only one mandatory argument, which is the value of the field.

    To use this feature, see Pods Admin > Settings under labels Display callbacks and Display callbacks allowed — one would need pll_e to be in the comma-separated list of allowed function names for it to be used in this way.

    If another function is desired in the future, but it requires more than one argument, one can write a wrapping function for display purposes, for example:

    <?php
    function display_callback_name( $field_value ) {
    return another_function( $field_value, 123, 'abc', [ 'some', 'values' ] );
    }

    …would allow {@my_field_name,display_callback_name} to display a calculated value, such as a translation, by passing the $field_value of my_field_name to a function named another_function with some default additional arguments of integer 123, text 'abc' and array/list [ 'some', 'values' ].

Viewing 1 replies (of 1 total)
  • The topic ‘Using Polylang in Pods template’ is closed to new replies.