How to change the footer of one page.

I'm building a plugin to create one page. I'd like to put the JavaScript right above the closing </body> on this page only.

How to do this?

Thank you

  • Extend page/elements/foot with your view and check if the URL matches the page you need. Haven't tested this, just typing from top of my head.

    // start.php
    elgg_extend_view('page/elements/foot', 'my/scripts');
    
    // views/default/my/scripts.php
    $site_url = elgg_get_site_url();
    $page_url = current_page_url();
    
    $page_path = substr($page_url, strlen($site_url));
    
    if ($page_path !== 'my/path') {
       return;
    }
    
    // echo stuff
    
  • Works great.

    Thank you Ismayil