Insert iframe in plugin

Hello, I'm updating the OpenMeetings plugin of Krasi to the latest version with OM 4.0.3. It's my way of getting more into Elgg programming.

I'm a little bit stucked with the implementation of the view of OM. In the old version it is done with the code:

$area1 = sprintf("<iframe src='%s' width='%s' height='%s'></iframe>",$iframe_d,"100%",640);        

$body = elgg_view_layout("one_column", $area1);
page_draw(elgg_echo('openmeetings:rooms'),$body);

page_draw is deprecated and should be replaced with elgg_view_page, so I modified in:

$body = elgg_view("one_colomn", array(
        'content' => $area1,
        'title' => $title,
        ));
echo elgg_view_page($title, $body);

I tried also some other possibilities, but when loading the page, it returns to de list view.

Can anyone tell me what I am missing here?

Please let me know if you need additional information.

  • I'm not sure if the problem is in this part of code you have updated. It does not look wrong. You could try with

    $content = elgg_view("output/iframe", array("src" => $iframe_d, 'width' => '100%', 'height' => '640px'));

    // layout 'content' or 'one_column' should both work
    $body = elgg_view_layout('content', [
        'content' => $content,
        'title' => $title,
    ]);

    echo elgg_view_page($title, $body);

    as there's an output view for iframes offered by Elgg. Layout could be either 'content' or 'one_column' to have a sidebar or not.

    My guess is that the problem might be some other part of code that you haven't updated properly yet. You might want to look into the error log and/or browser console to see if there are any entries explaining what might be wrong. Unfortunately, you won't get proper errors sometimes when updating plugins if you haven't fixed some outdated code yet as the execution doesn't even reach the part of code that would throw a useful error. So you might need to change a lot especially for old plugins before you can even start testing it properly. It can be frustrating especially at the beginning. But keep up trying.

    It might help to add some debug output like

    elgg_dump('This line of code reached', false, 'NOTICE');

    to know if the execution gets to the point at all you think the error is. You can also output variable values with the debug output if necessary.

    What you might need to do if you haven't yet is to replace usage of $CONFIG variable with elgg_get_config() as $CONFIG is no longer used by recent versions of Elgg. With elgg_get_config() you can get the necessary config variable values now.

  • Hi iionly,

    thanks for your reply.

    You were right. The problem was in some other part. A missing break in the page handler.

    Now the page stays on the view page, but no frame appears.

    I've made the changes you suggested.

    I have put a var_dump($iframe_d); above the elgg_view_page. It gives the following output.

    string(84) "http://localhost:5080/openmeetings/hash?&secure=6e1d67f5-9eda-4cbf-abdf-8786aa900c9a&quot;

    I also replaced the iframe src with a youtube link to see if it works, but without success.

    When I echo $content or $body I get an empty frame.

    Any suggestions?

  • OK, iframe works. I had the wrong youtube link.

    Just have to look further for embedding openmeetings.

    Thank you very much for your assistance.

  • Does the openmeeting session works if you directly call the url to be used in the iframe in the browser? If this doesn't work either the url might be wrong. Maybe the current version of openmeeting works differently compared to the version available back then when the openmeeting plugin was released.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking