pagesetup, system (deprecated in 2.3)

pagesetup, system (deprecated in 2.3)
Called just before the first content is produced. Is triggered by elgg_view(). Use the menu or page shell hooks instead.

 Greetings. Can anyone please explain this more in-depth? Before 2.3 I used to use

elgg_register_event_handler( 'prepare', 'page', 'mysite_pagesetup', 9999 );

and in 2.3 it doesn't work any more, obviously. How am I supposed to hide the right-side menu items now?
I've been trying to figure it out for a very long time now, tried

elgg_register_event_handler( 'shell', 'page', 'mysite_pagesetup', 9999 );

and

elgg_register_plugin_hook_handler( 'shell', 'page', 'mysite_pagesetup', 9999 );

to no avail.

BR,
ZP

  • Use

    register, menu:$name

    or

    prepare, menu:$name

    menu hooks.

  • So, according to Tools/Inspect/menu I have event_calendar, file, poll, groups:member and groups-add in owner_block. Setting

    elgg_register_plugin_hook_handler( 'prepare', 'menu:owner_block', 'mysite_pagesetup', 9999 );

    where

    function mysite_pagesetup () {
        elgg_unregister_menu_item( 'owner_block', 'event_calendar' );
        elgg_unregister_menu_item( 'owner_block', 'poll' );
        elgg_unregister_menu_item( 'owner_block', 'file' );
        elgg_unregister_menu_item( 'owner_block', 'groups:member' );
        elgg_unregister_menu_item( 'owner_block', 'groups-add' );
        echo "<h1>This should work?</h1>";
    }

    only works to the extent, that the function get called, as the heading "This should work?" is displayed just above the menu items, which don't get removed.

    BR,
    ZP

    Edit: same goes also for register, menu:owner_block.

  • I've a new version of the Event Calendar plugin in the works that will no longer use the deprecated 'pagesetup', 'system' hook. Unfortunately, I have no idea when I will be able to finish the work on this new version (as I just have no time for months already to do any work on it).

    The changes necessary for the menu issue in Event Calendar should be changing

    if (elgg_get_plugin_setting('ical_import_export', 'event_calendar') == "yes") {
        elgg_register_event_handler('pagesetup', 'system', 'ec_ical_pagesetup');
    }

    in the init function to

    if (elgg_get_plugin_setting('ical_import_export', 'event_calendar') == "yes") {
        elgg_register_plugin_hook_handler('register', 'menu:title', 'ec_ical_titlemenu');
    }

    and replacing the ec_ical_pagesetup function in start.php with

    // If iCal import/export is enabled add corresponding action buttons in title area
    function ec_ical_titlemenu($hook, $type, $return, $params) {
        if(!elgg_in_context("event_calendar")) {
            return $return;
        }
    
        $use_titlemenu = get_input('ical_calendar_title_menu', false);
        if ($use_titlemenu && elgg_is_logged_in()) {
            $filter = get_input('ical_calendar_filter', false);
            $date = get_input('ical_date', false);
            $interval = get_input('ical_interval', false);
            $group_guid = get_input('ical_group_guid', false);
    
            $export_url = elgg_get_site_url() . 'event_calendar/ical/export?method=ical';
            $import_url = elgg_get_site_url() . 'event_calendar/ical/import?method=ical';
            $urlsuffix = '';
    
            if ($filter) {
                $urlsuffix .= "&filter={$filter}";
            }
    
            if ($date) {
                $urlsuffix .= "&date={$date}";
            }
    
            if ($interval) {
                $urlsuffix .= "&interval={$interval}";
            }
    
            if ($group_guid !== false) {
                $urlsuffix .= "&group_guid={$group_guid}";
            }
    
            $export = new ElggMenuItem('ical_export', elgg_echo('event_calendar:export'), $export_url . $urlsuffix);
            $export->setLinkClass('elgg-button elgg-button-action');
            $return[] = $export;
    
            $import = new ElggMenuItem('ical_import', elgg_echo('event_calendar:import'), $import_url . $urlsuffix);
            $import->setLinkClass('elgg-button elgg-button-action');
            $return[] = $import;
    
            return $return;
        }
    }

    For other plugins similar changes should work.

    Are you sure that it's the Poll plugin listed or is it the Event Poll plugin? I also have a new version of the Event Poll plugin waiting to be released (want to release it together with Event Calendar though). In Event Poll the line

    elgg_register_event_handler('pagesetup', 'system', 'event_poll_pagesetup');

    before the init functions needs to be dropped and the line

    // page menu
    elgg_register_plugin_hook_handler('register', 'menu:page', 'event_poll_pagemenu');

    added inside the init function. And the funtion event_poll_pagesetup() gets replaced by

    function event_poll_pagemenu($hook, $type, $return, $params) {
        $context = elgg_get_context();
        if (!in_array($context, array('event_calendar', 'event_calendar:view', 'event_poll'))) {
            return $return;
        }
    
        elgg_load_library('elgg:event_calendar');
        elgg_load_library('elgg:event_poll');
    
        $poe = elgg_get_page_owner_entity();
        if (elgg_instanceof($poe, 'group')) {
            $group_guid = $poe->guid;
        } else {
            $group_guid = 0;
        }
    
        if (event_calendar_can_add($group_guid)) {
            if ($group_guid) {
                $url_schedule_event =  "event_calendar/schedule/$group_guid";
            } else {
                $url_schedule_event =  "event_calendar/schedule";
            }
    
            $schedule_event = new ElggMenuItem('event-calendar-1schedule', elgg_echo('event_calendar:schedule_event'), $url_schedule_event);
            $schedule_event->setSection('event_poll');
            $return[] = $schedule_event;
        }
    
        $url_list_polls =  "event_poll/list/all";
        $list_polls = new ElggMenuItem('event-calendar-2list-polls', elgg_echo('event_calendar:list_polls'), $url_list_polls);
        $list_polls->setSection('event_poll');
        $return[] = $list_polls;
    
        return $return;
    }

    The function event_poll_handle_event_poll_add_items() in model.php of Event Poll is no longer used either.

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