Breadcrumbs seem to be off when viewing an image in an og gallery.

This is when I'm looking at an image node for a particular gallery, for example

http://example.com/drupal/node/18

with the breadcrumb listed as

Home >> galleries >> Example Galleries >> Gallery

with Example Galleries linking to http://example.com/drupal/galleries/3
and Gallery linking to http://example.com/drupal/galleries/3/8

If I understand correctly, the 3 is the gid and the 8 is the tid?

The problem is that the 3 is incorrect, it should be linking to 1, this being an image in the group 1 gallery. I noticed this on my galleries for other groups as well, that when viewing the image node they all linked to group 3 instead of group 1, 2, 4 etc.

I tried adding a new gallery to another group, went to Adminisiter -> Categories and added the image type to the vocubulary for that gallery, uploaded an image and saw that the problem had shifted.

Now all images in all group galleries were using 2 as the gid in the bread crumbs.

I tried looking in og_galleries.module where breadcrumbs are handled but wasn't able to understand the code well. On the surface it looks like there's a part iterating through all the vocabularies and groups the user can see, and I've got a hunch that the crumb is being set to one of those and not necessarily to the proper $gid, just to one of the user's valid groups, but I can't determine that.

Sorry I'm struggling to describe this. I had little difficulty figuring out how to enable the galleries too, finally figuring out that I need to go to administer -> categories to add "image" to the types for the vocabulary for each category. There's still a good chance I just didn't configure this module right!

thanks,
Patrick

Comments

pcdonohue’s picture

All right,

I don't think I understood how this module was supposed to be used and somehow messed up some categories and taxonomy for the groups I had. I can't seem to get things back to normal either, I may disable this module, try to manually clean out the database, install the latest version you just posted, and try again. The alternative is to wipe out the groups I set up completely and then starting over... I'm doing this all on a test server, so no biggie.

Will report back after I do all that to see if I'm still having breadcrumb problems.

thanks,
Patrick

karens’s picture

I'm in the process of trying to really beat this up, so I may find other fixes to post. I am using your descriptions of problems and trying to make sure those things get followed up on. If you want to, you might wait a couple days to let me do that, they give it another go.

Yes, the path basically will be view-name/gid/tid, but since this uses views, there will be ways to change it if you have some other structure you want to use -- that's part of the reason for using views :-)

pcdonohue’s picture

Sure I can wait, I just tried reinstalling the package and clearing out the fields in the og_galleries table, then setup everything again, but the breadcrumbs are still behaving strangely.

I've got a separate question around usability and categories that I'll post as a separate issue, though it's possible that's it is related.

By the way, by nature writing about issues can make one sound sound unappreciative, so I'd just like to say, thanks so much for developing this module!!

cheers,
Patrick

karens’s picture

I think many problems were related to trying to use the module before things were setup correctly, so I have committed changes to the setup process, put in preventions to keep things that are not setup right from being used, added warnings to help clarify what needs to be done, and added a remove button in the settings section to make it easy to remove all traces and start over if the setup went wrong. You'll find the update in the cvs repository, the download file won't get updated until later.

Try this new version, go to admin/settings and use the remove button to remove the old install, re-install the module and get everything set up again, and see if there are still problems.

pcdonohue’s picture

Hi,

I did as you suggested, downloaded the update and used it to clear out the module and tables, but after setting everything up again (adding the view and going to each group so that a group gallery would be created) creating images in a group still ends up with the same behaviour, with the breadcrumb pointing to the wrong place.

If you're working on a number of updates to og_galleries, you can take your time on dealing with this issue, since I'm only using it on a test site and haven't been able to nail down exactly where the problem is. If I can get a better understanding of how breadcrumbs are built I could probably offer more help too.

thanks again,
Patrick

karens’s picture

StatusFileSize
new17.82 KB

You need an updated version of og_views.inc to get this working right. I posted a message in the project page and at http://drupal.org/node/79790 about the need for a patch to og_views.inc. Try substituting the attached file for the copy of og_views.inc in your og folder and see if that fixes your problems.

pcdonohue’s picture

Is this a new version of the patched og_views.inc?

Because I followed that thread and your project page discussions before installing og_galleries for the first time and had patched og_views.inc with the latest patch listed in the thread (og_views.inc_1.patch).

I tried doing a diff on the version you attached here and the patched version I was running with, but diff was getting caught up in some filesystem format differences (the attached one is listing as a DOS file and the diff is showing ^M for each line).

Still, replacing with what you've attached the behavior remains the same. It's still possible there's some legacy screw up I have in here from before that just isn't going away. I tried removing the galleries again and then setting them all up again, but I haven't tried removing all my groups and starting from scratch yet. That would be the next step to try. I assume you haven't been able to replicate the problem yourself.

thanks,
Patrick

karens’s picture

Sorry, I didn't remove the windows line endings on the file, but that is my replacement for the one I first proposed.

And yes, my breadcrumbs all look fine, so I can't replicate the problem. Let's try a fresh start and see if you still have problems.

pcdonohue’s picture

Well,

that didn't do what I wanted it do.... I deleted all of my groups and deactived og and all og_related modules, looked in the database to make sure the tables were clear and then re-added the modules.

I went through the setup for og_galleries, added some new groups, and then posted images to those groups. I now get the following warnings and error when I access images (and sometimes when I access the gallery page itself)



    * warning: Invalid argument supplied for foreach() in /home/donohues/public_html/bop/modules/node.module on line 359.
    * warning: implode() [function.implode]: Bad arguments. in /home/donohues/public_html/bop/modules/node.module on line 363.
    * user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE in /home/donohues/public_html/bop/includes/database.mysql.inc on line 120.

Does that look familiar to you and if so can you point to me where I might have done something wrong? Other than removing and adding back in the modules I've done nothing else and those messages are not very specific.

thanks,
Patrick

pcdonohue’s picture

All right, after much back tracking, module disabling and reenabling I was able to get the error message to go away, what wonderful ways I am discovering to crash drupal...

Now here's my dumb (potentially revealing) question for the day.

Do you use the image_gallery module? I think it comes with image and is described as "Allows sorting and displaying of image galleries based on categories".

Another potentially revealing question...

Do breadcrumbs come up when your viewing the image node itself
OR
when you are just viewing the galleries either at site.com/drupal/galleries (breadcrumbs being Home >> Galleries) or at site.com/drupal/galleries/x/y (breadcrumbs being Home >> Galleries >> GroupZ)?

I was seeing breadcrumbs in all those situations, when viewing the image, when viewing a particular group gallery, and when viewing all the users galleries. The breadcrumbs were linking to the wrong places though.

I have a hunch that problems have had something to do with having the image_gallery module enabled at one point or another. I think the image_gallery functionality messes with the og_gallery functionality, but I'm not sure. I guess I had just assumed it was needed or had just left it enabled. I don't remember reading you couldn't have both on at the same time, but I've missed things before...

Could that be the problem?

Patrick

karens’s picture

Aha! Yes, that's probably it. I didn't think to ask you if you had image gallery enabled. This module behaves much like image gallery, but for groups. It uses many of the same conventions, paths, etc, so you really should not have it enabled at the same time because there almost certainly will be collisions. Looks like I need to specifically mention that somewhere.

Do things work right with image gallery turned off then?

pcdonohue’s picture

StatusFileSize
new26.97 KB

Hi,

the breadcrumb seems to be working fine when I'm looking at the galleries pages, but a breadcrumb is still coming up on the image node itself and it's incorrect. See the attached image.

This image node is in the Main gallery of the BoP Protocol Commons group, yet it's listing a breadcrumb that says it's in the 2005 Protocol Design Workshop sub-gallery of the Main gallery. The links are incorrect too, in this image node, BoP Protocol Commons points to /drupal/galleries/55, Main points to /drupal/galleries/55/75, and 2005 Protocol Design Workshop points to /drupal/galleries/55/80 but the BoP Protocol Commons gid is 51 not 55.

Of course, I'm not even sure there should be a breadcrumb trail in the image node at all... is this an og module problem?

Patrick

pcdonohue’s picture

StatusFileSize
new251.11 KB

All right,

I may have tracked part of this down, the part that was making the link of the breadcrumb wrong

in your implementation of nodeapi

Note that you set $gid with a call to og_galleries_get_gid();

    case 'view':
      
      if (in_array($node->type, og_galleries_get_types())) {
        
        // get the gid for the current group context
        $gid = og_galleries_get_gid();
        // find the vid that matches it
        $vid = og_galleries_get_group_vid($gid);

But then you have a foreach loop that uses $gid as the key

        // figure out which vocabs are allowed to this user
        $galleries = og_galleries_get_vids();
        $allowed_groups = array_keys($user->og_groups);
        $allowed_vids = array(0);
        foreach ($galleries as $gid => $gvid) {
          if (in_array($gid, $allowed_groups) || $gid == 0) {
            $allowed_vids[] = $gvid;
          }
        }

So at the end of this, $gid may no longer have the same value as when you set it to og_galleries_get_gid() in the beginning, right? It could be referrring to a group other than the current group context, a gid of one of the other galleries.

This would be a problem when you later adjust the breadcrumb

        if ($page && $_SESSION['og_galleries']['base_tid']) {
          
          // if this is a page, adjust the breadcrumb
          $vocabulary = taxonomy_get_vocabulary($vid);
          $breadcrumb = array(array('path' => og_galleries_get_term_path($gid, ''), 'title' => $vocabulary->name));

So I changed the original foreach statement to use a different variable name than $gid as its key (in my case I just used $ggid) so that $gid would still retain the id of the current group context and the breadcrumb links are now pointing to the correct gids. Yay!

However, I still have the weird behavior seen in the last post's image where I am looking at an image in the gallery "Main" but the breadcrumbs are listing it as part of Main's subgallery "2005 Protocol Design Workshop". Further investigation shows that last breadcrumb term is showing up in images of other groups galleries too! See the attached image and note that "2005 Protocol Design Workshop" is part of the breadcrumb, even though that gallery is not in the "ESW & SGE" group galleries at all!

I'll look at this some more, something may be happening when you're traversing the parents array.

Patrick

pcdonohue’s picture

StatusFileSize
new26.17 KB

Sorry, something seemed to go wrong with that last screenshot I attached, here's another try.

Patrick

pcdonohue’s picture

All right, I may have tracked down the second problem too. This may be a bug from changes you made from version 1.1.2.6 to 1.1.2.7

Again in your nodeapi implementation for 'view'

You iterate through the node's taxonomy terms, and among other things you try to "use first term in the group context as the base tid for the breadcrumb"


        foreach ($node->taxonomy as $tid => $term) {
          if (in_array($term->vid, $galleries)) {
            if (!in_array($term->vid, $allowed_vids)) {
              // unset any gallery terms that shouldn't be seen by current user
              unset($node->taxonomy[$term->tid]);
            } 
            elseif ($term->vid == $vid && !isset($_SESSION['og_galleries']['base_tid'])) {
              // use first term in the group context as the base tid for the breadcrumb
              $_SESSION['og_galleries']['base_tid'] = $term->tid;
            }
          }
        }

You store the base tid in a session variable.
$_SESSION['og_galleries']['base_tid'] = $term->tid;

I think the problem comes in because the session variable can carry over to image views for other groups and may not be cleared out, because you only set a new one when an old one has not already been set.
elseif ($term->vid == $vid && !isset($_SESSION['og_galleries']['base_tid']))

That session variable for the tid is then used for the breadcrumb trail in the following code.

Does that sound accurate?

In version 1.1.2.6 you did this with a variable called $crumb_tid, is there a reason you switched over to using a session variable?

As an attempted fix, what I did was to create a local variable $base_tid_set for the conditional, but still stored the base_tid in a session variable.


        $base_tid_set = 0;
        foreach ($node->taxonomy as $tid => $term) {
          if (in_array($term->vid, $galleries)) {
            if (!in_array($term->vid, $allowed_vids)) {
              // unset any gallery terms that shouldn't be seen by current user
              unset($node->taxonomy[$term->tid]);
            }
            elseif ($term->vid == $vid && !$base_tid_set) {
              // use first term in the group context as the base tid for the breadcrumb
              $_SESSION['og_galleries']['base_tid'] = $term->tid;
              $base_tid_set = 1;
            }
          }
        }

That way the session variable is still being set (in case you had something else in mind globally that needed it) but the conditional is tested locally. With that fix I appear to be getting the correct behavior.

thanks,
Patrick

pcdonohue’s picture

Oh, one more thing, I'm not sure if you agree with this change to the breadcrumbs, but let me know what you think.

For the image I attached previously the now correct breadcrumb would be:
Home >> ESW & SGE >> Main

But I think I prefer having galleries also in the breadcrumb, so it's a little more obvious that the image is part of a gallery... so it instead would be
Home >> galleries >> ESW & SGE >> Main

This also makes it look more in line with the views pages where the breadcrumbs are
Home >> galleries
Home >> galleries >> ESW & SGE

To do this I just changed

$breadcrumb = array(array('path' => og_galleries_get_term_path($gid, ''), 
'title' => $vocabulary->name));

to

$breadcrumb = array(array('path' => og_galleries_get_url(), 'title' => t('galleries')), 
array('path' => og_galleries_get_term_path($gid, ''), 'title' => $vocabulary->name));

Patrick

karens’s picture

Whew! Thanks for all the work. I'll take a closer look tonight. The only problem I see is that 'galleries' is not necessarily the right name. That's the name the default view uses, but it can be changed, so instead the name of the galleries link is the title given to the galleries view and the path is the galleries view url.

mr john’s picture

Is there a final patch for this problem?

karens’s picture

Status: Active » Fixed

I've done a complete re-write of the module and issued new releases for both 4.7 and 5.x, and this issue should be fixed. If not, please re-open a new issue.

Anonymous’s picture

Status: Fixed » Closed (fixed)