• Resolved Peachey_A

    (@peachey_a)


    Hi Will,

    I’ve been using Insert PHP for a while to get around limitations in themes with visual builders. It’s wonderful!

    However, regrettably, one of my clients is using revolution slider, and required PHP logic run on the slider to dynamically link to a page. When adding the Insert PHP shortcode to a slide layer, the shortcode doesn’t fire, and the raw text is rendered via HTML, rather than being computed in PHP. Which sucks..

    I’ve tried to copy and paste shortcodes that are being used elsewhere on my site that do work, but again, in the slider they yield raw text, not the script output.

    The theme is based on Visual Composer, which hasn’t been an issue anywhere else.

    Any thoughts?

    https://www.ads-software.com/plugins/insert-php/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author WillBontrager

    (@willbontrager)

    What appear to be a shortcodes, [insert_php] and [/insert_php], don’t work like shortcodes. They serve as markers.

    Insert PHP scans the post or page content for those markers, runs any code found between them, and replaces the code and the markers with any output generated when the PHP was run.

    I’m unfamiliar with Revolution Slider and am uncertain what a slide layer is. Perhaps the Insert PHP plugin just doesn’t see it. Or perhaps the slide layer is copied into memory and then reinserted into the slide layer after Insert PHP would have run the code. Or maybe Visual Composer is doing something unexpected with the slide layer. Hard to tell, really, without testing, perhaps line by line.

    If what you need done can’t be done another way, perhaps with JavaScript or inserting content from an external PHP script, then it might be impossible.

    Will

    Thread Starter Peachey_A

    (@peachey_a)

    Hi Will,

    That’s a really sneaky way to use the shortcode notation, I like that a lot. Very clever.

    I’ll do some digging on Revolution Slider, for what you’ve said it sounds like it’s running post PHP execution, some kind of JavaScript cleverness.

    Thanks for getting back to me so quickly. Will keep thread open until I’ve found a solution and publish back here if it includes Insert PHP.

    Cheers,
    Andrew

    Thread Starter Peachey_A

    (@peachey_a)

    No way that I could find to resolve a conflict between InsertPHP and Revolution Slider.

    In the end I opted to used a javascript solution.

    Plugin Author WillBontrager

    (@willbontrager)

    Thank you for following up. It’s much appreciated.

    Will

    Hello @peachey_a,

    did you manage to solve how to insert php code into text/html layer in Slider Revolution?
    If yes, can you please share it with me?

    Thank you!

    Ante

    Thread Starter Peachey_A

    (@peachey_a)

    Hi @amedic

    Unfortunately, I didn’t find a tidy way to resolve the conflict. I ended up creating an empty element like this: <div id="rev_layer">&nbsp;</div> and then used javascript to target the id and add the content I needed.

    It will depend on what content you’re trying to get out of your Insert_PHP block as to whether this solution will work for you.

    If you were really desperate, a solution (though awful) would be to use Insert_PHP to get your content somewhere else on the page inside a container with an id and style="display:none;. Then move it with javascript after the page loads. As I say, this is about the worst approach possible, but it could solve the problem.

    Cheers,
    Andrew

    Hi @peachey_a,

    thank you for the fast reply!

    Basically I need to add this php code under my content in text/html layer:

    <?php
     $show_adv_search_general            =   get_option('wp_estate_wpestate_autocomplete','');
    if($show_adv_search_general=='no'){
     
        $availableTags=get_option('wpestate_autocomplete_data',true);
        
        print '<script type="text/javascript">
            //<![CDATA[
            jQuery(document).ready(function(){
                var availableTags = ['.$availableTags.'];
                jQuery("#search_location_autointernal,#search_location_mobile_autointernal,#search_location_filter_widget_autointernal,#search_location_filter_shortcode_autointernal,#search_location_filter_autointernal").autocomplete({
                    source: function(request, response) {
                        var results = jQuery.ui.autocomplete.filter(availableTags, request.term);
                        response(results.slice(0, 10));
                    },
                    select: function (a, b) {
                        jQuery(".stype").val(b.item.category);    
                    
                        if (document.getElementById("search_location_filter_autointernal")) {
                       
                            jQuery("#search_location_filter_autointernal").val(b.item.label);
                            start_filtering_ajax_map(1);
                        }
                    }
                });
            });
            //]]>
        </script>';
    }
    ?>

    It is a JS inside php code. It is showong available tags for the autocomplete. It is taking them from the php variable $availableTags.

    Thank for the help!

    Thread Starter Peachey_A

    (@peachey_a)

    Hi @amedic,

    I’ve had a look at the code, and I think I understand what you’re doing. My only real suggestion would be to echo the $availableTags into a hidden container, and then run the javascript in the footer of the page.

    That might not make sense for what you’re trying to achieve, but that’d be my best guess at a workaround I’m afraid.

    Good luck!
    Andrew

    Hi @peachey_a,

    or I could get those variable with the shortcode, and run short code in the text/html layer of the Slider. I think it can run shortcodes.

    Thanks for your help, you really helped me!

    Bye

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Insert PHP and Revolution Slider?’ is closed to new replies.