• Resolved davedw

    (@davedw)


    Hi,

    I’ve managed to find a way of getting some of the data I was manually having to update on the page as a variable, directly from an API and available as a short code, wondering if you can help me get this working with CF please?

    Current example of one of the variables is: [CP_CALCULATED_FIELDS_VAR name=”EDFGESRSC” value=”0.3605″] 

    Ideally, I’d like to replace the value within value=”” with [code_snippet id=7 php format]

    I’ve tried several ways of doing it, but with no success, is this something you can help me with please?

    Thanks in advance!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @davedw

    That’s not possible. WordPress does not allow inserting a shortcode into the attributes of other shortcodes.

    However, you can insert a script tag directly on your page’s content:

    <script>EDFGESRSC='[code_snippet id=7 php format]';</script>

    WordPress includes the “Custom HTML” block to insert custom pieces of code.

    Best regards.

    Thread Starter davedw

    (@davedw)

    Many thanks for the quick reply @codepeople

    Using custom HTML and putting in the above didn’t show me any errors, but the value didn’t get used in the form, does anything need to be done to tell it that it the CP_CALCULATED_FIELDS_VAR part?

    Plugin Author codepeople

    (@codepeople)

    Hello @davedw

    If the variable exists on the page, the plugin will use it. Please, indicate the URL to the page that contains the variable to be sure your website generates it properly.

    Best regards.

    Thread Starter davedw

    (@davedw)

    Hi @codepeople

    I’ve temp published my test page: https://www.teslaev.co.uk/cost-to-charge-calc-2/

    The variable (which I can see in source) is: OctGoSpecial using the same format you specified above

    Plugin Author codepeople

    (@codepeople)

    Hello @davedw

    Please, take a look to your page’s source. The third-party shortcode is being replaced as follows:

    <script>OctGoSpecial='<p>16.401</p>
    ';</script>

    It includes the value between p tags, and a carriage return before closing the text.

    Please, look at the screenshot image below:

    Best regards.

    Thread Starter davedw

    (@davedw)

    Thanks again for your help @codepeople – I know this is now out of the realms of your excellent plugin, but could the theme be adding that?

    In the code snippet, I’ve even set it to strip the output so it’s plain text and it’s still doing it?

     // Capture the output without HTML tags
        ob_start();
        echo "{$unitRate}\n";
        $output = ob_get_clean();
    
        // Strip HTML tags from the captured output
        $output = strip_tags($output);
    
        // Display the output
        echo $output;
    Thread Starter davedw

    (@davedw)

    I’ve worked this out now @codepeople

    There was a formatting option on within code snippets and the <scripts> section should not have the ‘ for it to work.

    Thanks for your help in getting me here!

    Plugin Author codepeople

    (@codepeople)

    Hello @davedw

    Excellent !!!!. Thank you very much for sharing your solution.

    Best regards.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Using an external shortcode with the CF plugin?’ is closed to new replies.