OG tabs to render a custom hook_menu

Created on 16 November 2010, about 14 years ago
Updated 28 October 2024, about 2 months ago

Hi All,

First of all, thank you for this great module that I enjoy using it.

I have an issue with og that couldn't find anything similar to solve. So I just post here to look for a help.

I have two custom modules and each of them implement hook_menu as:

module 1:

<?php
function FIRST_MODULE_menu(){
	$items = array();
	//path to load the node with new parameters
	$items['node/%/abc/%'] = array(
		'title'	 => 'Custom Content ABC',
		'access callback'	=> 'user_access',
		'access arguments'	=> array('abc'),
		'page callback'	 => 'first_module_node_load',
		'page arguments'  => array(3,4,5),
		'type'	 => MENU_CALLBACK,
	);
	
	return $items;
}
//callback function
function first_module_node_load($param1, $param2, $param3) {
 //load the node with the nodeid = $param1
 $node = node_load(array('nid'=> $node_id));

 //manipulate $custom_content according to $param2 and $param3 and append its to node
 $custom_content = $param2 + $param3;

 $node->content['custom_content'] = array(
	'#value' => $custom_content,
	'#weight' => 0
 );
						
 //Return the node to display
 return node_view($node, FALSE, TRUE);
}

?>

And the code of module 2
module 1:

<?php
function SECOND_MODULE_menu(){
	$items = array();
	//path to load the node with new parameters
	$items['node/%/xyz/%'] = array(
		'title'	 => 'Custom Content XYZ',
		'access callback'	=> 'user_access',
		'access arguments'	=> array('XYZ'),
		'page callback'	 => 'second_module_node_load',
		'page arguments'  => array(3,4,5),
		'type'	 => MENU_CALLBACK,
	);
	
	return $items;
}
//callback function
function second_module_node_load($param1, $param2, $param3) {
 //load the node with the nodeid = $param1
 $node = node_load(array('nid'=> $node_id));

 //manipulate $custom_content according to $param2 and $param3 and append its to node
 $custom_content = $param2 + $param3;

 $node->content['custom_content'] = array(
	'#value' => $custom_content,
	'#weight' => 0
 );
						
 //Return the node to display
 return node_view($node, FALSE, TRUE);
}

?>

The code of these two modules work just fine when I manually visit URL that match these hook menu.

Now I want to place these menu items under tabs of Organic Group. So here is what I did:

Create a view and add a page display into the view.
1. Under basic settings -> Row Style -> Select node
2. Under Argument -> Select Organic groups: Groups.
- Action to take if argument is not present: Hide view / Page not found (404)
- Validator options:
+ Validator: Group nodes
+ Argument type: Node Id
+ Group membership validation: Do not validate user's group memebership
+ Group node types: select a node type that is set as group node
3. Under page settings:
- path: http://localhost:8082/node/%/abc/112/500/7000
- Menu: select Menu tab -> enter Title ABC and the weight.

By the above setup, I have ABC appear as a tab on the organic group homepage when I visit it. When I click to the tab -> the above custom hook_menu (node/%/abc/%) render nicely. However, when it render I lost all the tabs in organic groups.

I then do the same step above to add another page display under the same view and do the same setting except tht path under 3. is changed to http://localhost:8082/node/%/xyz/113/400/800

Surprisingly that the second tab is displayed but when I click on it, it doesn't render the second custom menu item above (node/%/xyz/%).

I have compare everything between these two identical setup and couldn't figure out why one is rendered and the other not?

Any help on this would be very much appreciated.

Truyenle

πŸ’¬ Support request
Status

Closed: outdated

Version

2.1

Component

og.module

Created by

πŸ‡ΊπŸ‡ΈUnited States truyenle

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024