• Resolved abruneau0

    (@abruneau0)


    Hi and thanks for your extensive work on this great plugin.

    I’m trying to get the external render for the Flexible field and I work with Oxygen Builder, which is a themeless page builder.
    In my quest to get it working, I found this link that give me the control of the root file for my different templates.
    The hook works great, as it updates the prefix on render fields inside my Flexible.
    Changing /wp-content/themes/twentynineteen to https://www.website.com/wp-content/block/.

    But I can get it to display anything (neither php, or css, which the one I tested)
    I follow your page as close as possible, but I’m afraid there is a naming convention of some sort I’m not aware off.

    The function ...the_flexible('flexFieldName');... appears to be outputing well, as I can see the Block name as comment inside the rendered HTML.

    Here is a attached screenshot of my current flexible render path configuration.

    To sum up naming I used :

    • Flexible field name : ‘flex-project’
    • Flexible layout : ‘flexible_photo’
    • Path to PHP : /flex-project/flexible_photo/template.php
    • Path to CSS : /flex-project/flexible_photo/style.css

    Are thoses correct ?

    I hope I’m clear enough, and will be happy to share more informations !
    Thanks in advance for your help.

    Aristide

    • This topic was modified 4 years, 11 months ago by abruneau0.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback. I think there’s a misundertanding here, because the tutorial you linked is about the ACF Block Type feature (which has an UI in ACF Extended). In your question you’re talking about the Flexible Content: Dynamic Render, which is an another feature.

    Flexible Content: Dynamic Render feature use locate_template() to include a template files, but before that, it checks if the file exists first.

    You can take advantage of available hooks here. You’ll find some examples in the FAQ section here.

    For what you need, you can probably use the following code:

    
    // Add custom prefix path for all Flexible Content Layouts Templates
    add_filter('acfe/flexible/render/template', 'acf_flexible_content_change_template', 10, 4);
    function acf_flexible_content_change_template($template, $field, $layout, $is_preview){
        
        return ABSPATH . '/wp-content/plugins/my-plugins/layouts/' . $template;
    
    }
    
    // Add custom prefix URL for all Flexible Content Layouts Style files
    add_filter('acfe/flexible/render/style', 'acf_flexible_content_change_style', 10, 4);
    function acf_flexible_content_change_style($style, $field, $layout, $is_preview){
        
        return home_url() . '/wp-content/plugins/my-plugins/layouts/' . $style;
    
    }
    
    // Add custom prefix URL for all Flexible Content Layouts Scripts files
    add_filter('acfe/flexible/render/script', 'acf_flexible_content_change_script', 10, 4);
    function acf_flexible_content_change_script($script, $field, $layout, $is_preview){
        
        return home_url() . '/wp-content/plugins/my-plugins/layouts/' . $script;
    
    }
    

    Hope it helps!

    have a nice day.

    Regards.

    Thread Starter abruneau0

    (@abruneau0)

    Hey and thanks for your answer, it helps a lot !

    I just tried the code you share, and everything seems to work !

    Apart from the ‘prefixs’ inside the flexible field configuration, which still display the theme path, but PHP, CSS and JS files load well !

    Thanks again ! I’ll keep an eye on the post if you have a solution to display the right path prefix, but that’s not mandatory for me to start working on it ??

    Have a nice day too
    Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Flexible external render path’ is closed to new replies.