Integrate into User's Profile, Pages or Groups App
Integrate into User's Profile, Pages or Groups App
Support user's profile submenu
Implement hooks "mobile.service_userapi_getprofilemenu_end.php" using the following example code to add a menu to the user's profile page
mobile.service_userapi_getprofilemenu_end.php
<?php
/**
- Add post navigation to user profile menu
*/
if (isset($query) && isset($local) && isset($result) && Phpfox::isModule('post') && isset($user)) {
$result['post'] = [
'label' => $local->translate("posts"),
'path' => "post/list-item",
'params' => [
'headerTitle' => $local->translate('full_name_s_item', ['full_name' => $user['full_name'], 'item' => $local->translate("posts")]),
'query' => $query,
],
];
}
Verify User Detail Api to make sure your code works
API Call: /user/{user_id}?access_token=token
Support pages detail app submenu
if your app integrate when Pages app, In this case, we need to add a menu to view all items belong to the page and a button to allow to create a new post in page
Add new Hook "/mobile.service_pageapi_getprofilemenu_end.php" in your app using the following code
mobile.service_pageapi_getprofilemenu_end.php
<?php
if (isset($query) && isset($local) && isset($result) && Phpfox::isModule('post') && isset($page)) {
$result['post'] = [
'label' => $local->translate("posts"),
'path' => "post/list-item",
'params' => [
'headerTitle' => $local->translate('full_name_s_item', ['full_name' => $page['title'], 'item' => $local->translate("posts")]),
'query' => $query,
// Add create button
'headerRightButtons' => [
[
'icon' => 'plus',
'action' => Screen::ACTION_ADD,
'params' => [
'resource_name'=> 'post',
'module_name'=> 'post',
'query' => [
'item_id' => $page['page_id'],
'module_id' => 'pages'
]
]
]
]
],
];
}
Now, verify Get Detail Pages API to make sure it has response your integration
API Call: /pages/1?access_token=token
Support groups detail app submenu
if your app integrates with Groups app. we need to add a menu to view all items belong to the group and a button to allow to create a new post in the group
Add new Hook "/mobile.service_groupapi_getprofilemenu_end.php" in your app using the following code
mobile.service_pageapi_getprofilemenu_end.php
<?php
if (isset($query) && isset($local) && isset($result) && Phpfox::isModule('post') && isset($page)) {
$result['post'] = [
'label' => $local->translate("posts"),
'path' => "post/list-item",
'params' => [
'headerTitle' => $local->translate('full_name_s_item', ['full_name' => $page['title'], 'item' => $local->translate("posts")]),
'query' => $query,
// Add create button
'headerRightButtons' => [
[
'icon' => 'plus',
'action' => Screen::ACTION_ADD,
'params' => [
'resource_name'=> 'post',
'module_name'=> 'post',
'query' => [
'item_id' => $page['page_id'],
'module_id' => 'pages'
]
]
]
]
],
];
}
Now, verify Get Detail Groups API to make sure it has response your integration
API Call: /groups/{group_id}?access_token=token
The response would be the same as Pages integration