• Resolved RAM64

    (@ram64)


    Hi, thank you for all the hard work that the developers put into PODS. I have been using this for a few years now and it’s amazing. However, with the latest release (3.2.7) I noticed that “PHP support for Pod Templates and Pod Pages” has been turned off by default and that it will be removed from version 3.3. Most of my custom pods will have at least some bit of PHP included (for example for calculating difference between two fields) and I use Auto Templating. I tried searching for alternatives on how to achieve this without PHP, but I can’t seem to find anything in the documentation. Right now I manually enable PODS_DISABLE_EVAL in wp-config. But once 3.3 is out, that won’t work anymore.

    Could someone advise on how to do templates without PHP support when dynamic computations are needed?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Same problem here ??

    Moving functions and calculations out of the template with code snippets and inserting results into the template worked for me.

    Sample: https://docs.pods.io/code-snippets/return-calculated-value-pods-template/

    Custome Code with pods: https://docs.pods.io/faqs/where-should-i-put-code-for-use-by-pods/

    Plugin Support Paul Clark

    (@pdclark)

    Yes, helper functions can be used in case where a new function would take a single field value as an argument.

    For more complex logic, the simplest route is usually adding a shortcode:

    // Calculate the difference between two fields.
    // Usage: [difference field1="field1_name" field2="field2_name"]
    add_shortcode(
    'difference',
    function( $atts, $content, $tag ) {
    $pod = pods();
    $value1 = $pod->field( $atts['field1'] );
    $value2 = $pod->field( $atts['field2'] );


    return sprintf(
    '<pre>
    The field named <code>%s</code> contains %s.
    The field named <code>%s</code> contains %s.

    The field1 minus field2 is %s.
    </pre>',
    $atts['field1'],
    $value1,
    $atts['field2'],
    $value2,
    number_format(
    ( floatval( $value1 ) - floatval( $value2 ) ),
    2,
    '.',
    ','
    )
    );
    }

    );
    Thread Starter RAM64

    (@ram64)

    This is great. Thank you for your replies. It makes a lot of sense now.

    manuel1610

    (@manuel1610)

    Hi , I cant use: define( ‘PODS_DISABLE_EVAL’, true ); it doesnt work in my wp-config.php

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @manuel1610

    By setting it to true you are actually disabling it. Try setting it to false and PHP will work again. But as mentioned, this is deprecated so I would suggest switching to the helper functions as described above.

    Cheers, Jory

    Jeff

    (@jefftobler)

    Hi Guys, hey this is big issue for us as we have PHP functions interspersed throughout our templates and is necessary for what we’re doing. Why the need to depricate and ultimately remove? Could you please reconsider and keep this functionality?

    If not, this involves a lot of heavy lifting for us. Does it work to use PHP shortcode inserts (such as WP CODE Lite)?

    Plugin Support Paul Clark

    (@pdclark)

    @jefftobler Yes shortcodes are a viable standard way of inserting PHP into content. Also see add_shortcode.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.