1

I'm loading a group node from a custom menu item I've created in a module. The reason I've created a custom menu item is because I wanted to use a different path than the one associated with the node.

I have a panel with a selection rule set to all group nodes. The custom menu item works and loads the group node, however, the panel is not being activated. I think it is something to do with the way I am loading the node from my hook_menu function which is preventing the context from being activated. The code I'm using is:

function mymodule_menu() {

$items['course/course-1/resources'] = array(
    'title' => 'Resources',
    'access callback' => TRUE,
    'page callback' => '_getpage1',
    'page arguments' => array(1),
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'menu-course-menu',
    'weight' => '1',
);

return $items;

 }


function _getpage1($arg1) {
    $path = drupal_get_normal_path("course/" . $arg1);
    $node=menu_get_object('node',1,$path);
    return node_page_view($node);
 }

Is there anything I need to add to activate the context for the group?

Many thanks,

Ben

ADDTIONAL INFORMATION:

I have two variants set up.

For the first:

Selection rule: Node is an OG group AND path matches "course/*/resources".

Context: No context is set

Relationship: OG Group from node

For the second:

Selection rule: Node is an OG group.

Context: No context is set

Relationship: OG Group from node

The first variant is supposed to be activated for the same group node when the path "course/course-1/resources" is used, and the second is supposed to be activated when the path is simply "course/course-1". At the moment only the second variant is being activated. When the path "course/course-1/resources" path is used it just shows the Course 1 group node in it's default layout with no panels being used.

3
  • Please provide info on how the panel is configured including its path, selection rules, contexts and relationships.
    – Ashlar
    Mar 9, 2012 at 17:29
  • Hi Ashlar, I've updated my question with more information above.
    – Ben
    Mar 9, 2012 at 18:56
  • What is the basic path for the page panel?
    – Ashlar
    Mar 9, 2012 at 22:32

2 Answers 2

1

I like to test a panel answer before I post it, but will be gone for a couple days, so I'll give you my speculation on what may be causing this. I suspect your page panel path is /course/%course and so that is the only path that is intercepted. It does not matter that you have a variant for resources because it never gets tested. The basic panel definition has already rejected it. Try changing the basic path to /course/%course/!other. The !other variable is optional so the panel should intercept 2 and 3 level paths matching the pattern. Your variant should then be triggered.

The variable labels in the path (%course & !other) are used to identify associated contexts listed on the context/relationships tab for defining the variant and the specific label name does not matter. Hope this works. If not, I'll check back in a couple days.

9
  • Hi Ashlar, thank you very much for your answer. I'm knew to panels so may well be making a mistake somewhere. I didn't create an additional page panel but overrode the system node template at node/%node. I have been trying to create a new page panel based on the path you suggest above but I can't get it to work at all now. I'm going to carry on trying and will keep you posted.
    – Ben
    Mar 11, 2012 at 13:56
  • I've been trying different things, and one way I tried to activate the panel was by making the keyed path in my hook_menu function be just "/test". But this has the same effect and doesn't activate the page panel (based on the "node/%node" system template override. So I'm not sure that it's not working has something to do with the last path argument. It does seem to have something to do with the fact that the path (alias) is not saved internally in Drupal. When I save the alias "/course/course-1/resources" to go to "node/1" (my course page) then the panel does get activated.
    – Ben
    Mar 11, 2012 at 14:38
  • Maybe the problem is linked to the question at drupal.stackexchange.com/questions/789/…?
    – Ben
    Mar 11, 2012 at 14:40
  • Try defining a node as I suggested to test it, but do so using the panels UI (its quicker and less can go wrong). Let me know what happens.
    – Ashlar
    Mar 11, 2012 at 17:19
  • I tried defining a panel page based on "course/%course" (I disabled my other panels), but it is not activating for any of the course group pages. I'm also unclear using this method how I will relate my group content to the panel. I could do this in the node override panel by using the Group from node relationshiop, but this is not available in this panel.
    – Ben
    Mar 12, 2012 at 12:58
0

I managed to solve the problem. I did some research and a post at Url aliases and arguments/ Panels put me on the right track.

The Drupal path module does not match sub-paths but only full URLs, so I downloaded and enabled the Sub-pathauto module and then the panels were being activated correctly. Now I can have different variants activated by different arguments at the end of the URL (ie alternative displays for the same organic group node). I needed this module as I was using aliases. So there was nothing wrong with the panel set up it was just the sub-path was not being added for Drupal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.