• Resolved streamworksaudio

    (@streamworksaudio)


    Hi again,

    Another question….

    Is there a way to somehow filter the content of a popup’s content?

    I would like to have a button with a popup class, but the contents of that popup I would like to dynamically change.

    I was thinking this may somehow be possible by filtering the content of a popup.

    Cheers

    https://wordpress.org/plugins/popup-maker/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Daniel Iser

    (@danieliser)

    @streamworksaudio – Wouldn’t work the way you hope. Popup content is filter able during page load. But popups are rendered at that time not when the button is clicked.

    What your after requires using JS to either pass variables from the button to Ajax or rerender the variable content using JS.

    You can check out our Remote Content extension which has an API built in to allow you to quickly make an Ajax setup. You can set the data passed from the button to Ajax and define a php function to catch the response. We handle everything else. Whatever you echo in that php function will be shown in the popups. With that you can make one popup and dynamically generate content from hundreds of buttons.

    Hope that helps.

    Thread Starter streamworksaudio

    (@streamworksaudio)

    I assume that the plugin uses AJAX to retrieve the ‘content’ from the post (popup post type)? And I assume that the CSS class then uses Javascript to render the AJAX response? This is a question just so I have a better idea of the plugins process.

    With the Remote Content extension, would this then allow me to have the AJAX call return whatever response from my custom function?

    In other words… I create a blank Popup post (let’s give it an ID of 100). Then I create a button or link (or other clickable element) with the class of popup-100 -> this then (via Javascript) runs some AJAX that then runs a custom function and the response then populates the popup box?

    Sorry for so many questions – I am just trying to see if this is possible. At the moment I am using a simple jQuery/PrettyPhoto plugin and with it I can pass some HTML (iframe etc), but I really just want to pull in the content of a post not a whole page that iframe would pull in.

    Cheers

    Plugin Author Daniel Iser

    (@danieliser)

    @streamworksaudio – Here is our doc on the feature for reference: http://docs.wppopupmaker.com/article/33-remote-content-ajax-setup.

    You nailed it. You can do whatever you like in the AJAX php function, you can also pass additional info via JS. For example

    You want full user profiles to appear in a popup in your member directory. So in your beforeAJAX JS you would add their member ID to the data array pulling it from the html wrapping the button.

    <div id="member-123" data-member-id="123">
        <button>View Profile</button>
    </div>

    Pro Tip: So in this case you can also use Click Open Settings -> Extra Selectors to target your own selectors for clicking rather than adding the popmake-100 class to everything. In this case you could enter [data-member-id] button into the Extra Selector to target the profile button.

    So your JS would look like this for the example given:

    $('#popmake-100').on('popmakeRcBeforeAjax', function () {
        var $trigger = $($.fn.popmake.last_open_trigger);
    
        $.fn.popmake.rc_user_args[100] = {
            member_id: $trigger.parent().data('member-id')
        };
    });

    Hope that helps.

    Thread Starter streamworksaudio

    (@streamworksaudio)

    Hi Daniel,

    Sorry for the delay. I will have a look into this further when I get some time.

    But in a nutshell – if it is easy and painless to use the plugin and AJAX to dynamically generate the content that populates a popup, then I would be interested.

    Cheers

    Plugin Author Daniel Iser

    (@danieliser)

    @streamworksaudio – AJAX and WP in general are rather simple but we are taking it even further to make Ajax content in Popups as simple as possible. So only 2 things your end up having to do.

    Tell it what data it needs to pass and then use the passed data to render content.

    Hope that helps.

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

The topic ‘Dynamic Content’ is closed to new replies.