all views to extend

Is it possible to extend every view with my plugin view, or do I have to count them manually in start.php?

  • Thanks, Okay, I know that guide, but if the plugin view should be shown on every elgg page, I have to insert all views manually into start.php? A good example for this requirement is the Shareaholic plugin which shows buttons fixed on the bottom left side. This is also only shown on the start page and has the init option:

    elgg_extend_view('object/summary/extend','Shareaholic/Shareaholic');

    Isn't there any possibility to see this on every (internal) page?

  • I know it's been a long time since you asked this question but I came looking so I figured someone else might too. 

    I don't think there is a clean way to do what you're describing, however you can contextually extend whatever view they all have in common. For example,  most likely all of your view will eventually run through the "page/elements/body" view (or "page/layouts/content", etc). 

    So your start.php can look something like this:

    <?php
    elgg_register_event_handler('init', 'system', 'plugin_init');
    
    function plugin_init() {
        elgg_register_event_handler('pagesetup', 'system', 'pagesetup_handler', 1000);
    }
    
    function pagesetup_handler() {
        if (elgg_is_active_plugin('PLUGIN_NAME') && elgg_is_logged_in()) {
          if (elgg_get_context() == "CONTEXT") {
              elgg_extend_view('page/elements/body', 'other/view', 501);
        }
    }

    I use this to add an AJAX modal to plugin forms. 

  • Adam, we recommend moving away from the pagesetup event if possible. It will likely be formally deprecated soon.

    Problem being it's tied to the first elgg_view() call, which is a very unreliable indication of "about to build a page".

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