When creating multiple panel pages per group, the non-Home page panel pages don't have their page title set correctly.

The code on line 484-486 of og_panels.module appears to set the title of the page to the current panel, but in reality, every panel page for the OG has the same title as the OG node.

-mike

Comments

jimthunderbird’s picture

This issue can be fixed by modifying function og_panels_nodeapi($node, $op) in og_panels.module, make it look like the following:

function og_panels_nodeapi($node, $op) {
  switch ($op) {
       case 'load':
            $title = db_result(db_query("SELECT page_title FROM {og_panels} WHERE nid = %d AND default_page = 1", $node->nid));
            $node->title = $title;
            break;
       case 'delete':
       if ($og_panels = og_panels_get_all($node->nid)) {
         foreach ($og_panels as $og_panel) {
          panels_delete_display($og_panel->did);
        }
        $sql = "DELETE FROM {og_panels} WHERE nid = %d";
        db_query($sql, $node->nid);
        drupal_set_message(t('Organic groups panel pages deleted.'));
      }
      break;
  }
}
ultimike’s picture

Jim,

This change doesn't work for me - all of my non-home page OG panel pages still have the title of the OG home page. Your fix seems like it would attempt to set the title of every page on site, shouldn't it only be focused on OG panel pages?

Thanks,
-mike

jimthunderbird’s picture

Hi Mike,
Thanks for the feedback. From what I observed, all og panel pages title are set properly except the home page one. I will come up with another fix later. Also, for you info, I'm running Drupal 6.16 and OG 6.x-2.1.

Best Regards,
Jim

jimthunderbird’s picture

Update: Please see #6 on the improved solution

ultimike’s picture

Jim,

Thanks for the quick response, but I don't think your code will do the trick.

It looks like the query you're using in the "load" $op will grab the title of the default (home) panel for the OG in all cases. What I'm actually looking for is the title of the panel that the user is currently viewing (I believe this is gained via the panel's display ID). I've tried to figure out how to grab the display ID then perform a similar query to what you have above, but to no avail.

Know what I mean?

Thanks again,
-mike

jimthunderbird’s picture

Hi Mike,
Thanks for the reply again. I've made another fix, just replace the og_panels_nodeapi function with the following and hopefully this works.

function og_panels_nodeapi($node, $op) {
  switch ($op) {
    case 'load':
      if(og_is_group_type($node->type) && $node->nid == arg(1)){
        if(arg(2) == 'og-panel'){
          $did = (int)arg(3);
          if($did > 0){
            $result = db_query("SELECT page_title FROM {og_panels} WHERE nid = %d AND published = 1 AND default_page = 0 AND tab_num = %d", $node->nid, $did);
            $row = db_fetch_object($result);
            if(is_object($row)){
                $node->title = $row->page_title;
            }
          }
        }
        else{
          $result = db_query("SELECT page_title FROM {og_panels} WHERE nid = %d AND published = 1 AND default_page = 1", $node->nid);
          $row = db_fetch_object($result);
          if(is_object($row)){
            $node->title = $row->page_title;
          }
        }
      }
      break;
    case 'delete':
      if ($og_panels = og_panels_get_all($node->nid)) {
        foreach ($og_panels as $og_panel) {
          panels_delete_display($og_panel->did);
        }
        $sql = "DELETE FROM {og_panels} WHERE nid = %d";
        db_query($sql, $node->nid);
        drupal_set_message(t('Organic groups panel pages deleted.'));
      }
      break;
  }
}

Best Regards,
Jim

jimthunderbird’s picture

I retested this fix and found that this is doing the trick.

Best Regards,
Jim

ultimike’s picture

Status: Active » Needs review

Jim,

Great - thank you. This looks good, seems to be working for me. I'll continue to test it on a dev site I have. In the meantime, I've changed the status to "needs review" so hopefully some other people can bang on it a bit.

Thanks for your help.

-mike

populist’s picture

Status: Needs review » Fixed

great. commited.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.