How to add a subpage like "Members" in the group page

Kevin Ngo Posted in Component Development 8 years ago

Hi,

How can I add a subpage that is similar to Members in OssnGroup. I would like to add my own functionalities in the new subpage. As of right now, I can create a link but I'm having trouble creating a new subpage. I want the new subpage to be next to "Members" in the group page.

Or, if possible, how can I assign a feature similar to the "Add Group" function in the sidebar on the left side, where it brings up a form and you enter the information. So when I click on the link in the group, I can bring up a form and enter information from there.

Replies
Indonesian Arsalan Shah Replied 8 years ago

In you component ossn_com.php file you need to add following code:

function mycomponent_init() {
                ossn_group_subpage('newpage');
                ossn_add_hook('group', 'subpage', 'mynewpage_groups');
                ossn_register_callback('page', 'load:group', 'mycomponent_group_load');
}
function mynewpage_groups($hook, $type, $return, $params) {
                $page = $params['subpage'];
                if($page == 'newpage') {
                                $contents = ossn_plugin_view('mycomponent/newpage', $params);
                                $page     = array(
                                                'title' => 'New Page',
                                                'content' => $contents
                                );
                                echo ossn_set_page_layout('module', $page);
                }
}
function mycomponent_group_load($event, $type, $params) {
    $owner = ossn_get_page_owner_guid();
    $url   = ossn_site_url();
    ossn_register_menu_link('newpage', 'newpage', ossn_group_url($owner) . 'newpage', 'groupheader');
}

After that you need to create new file in

components/mycomponent/plugins/default/mycomponent/newpage.php

In newpage.php you can add your contents.