Breadcrumb in User Profiles

drupalthing - July 15, 2009 - 14:30
Project:Custom Breadcrumbs
Version:6.x-2.x-dev
Component:custom_breadcrumbs
Category:bug report
Priority:normal
Assigned:MGN
Status:fixed
Description

I have this problem:

In Pathauto I have defined "Pattern for user account page paths" as "people/[user-raw]"

Now I want to reflect this path with Custom Breadcrumbs. In the node type Profile I have set Titles with "People" and Paths with "people".

This works for me as a logged in user. (Home > People > My account)

Yet for any other user, the breadcrumb looks like this: Home > User Name > User Name. And the first "User Name" is linked to http://user/11, an adress without the domain.

Any ideas?

#1

MGN - July 30, 2009 - 22:16
Status:active» postponed (maintainer needs more info)

From your description, the breadcrumb for the loged in user doesn't look correct. It should be Home > People . So the question is, where is My account coming from (since you don't have that in your custom breadcrumb). Most likely, your theme or another contrib module is changing the breadcrumb.

Is this the only node type that you are having problems with ?

Is your Profile node type just a custom node type or is it provided by a contrib module?

If you change themes (to a core theme), does anything change?

#2

locomo - August 22, 2009 - 00:20

i'm seeing the similar behavior as drupalthing

i've tried changing the theme to a core theme with the same result

in my setup i'm using content_profile, realname and auto_nodetitle

when i'm logged in and editing another user account i have two tabs: account and user profile

when editing another user's account tab the breadcrumb is:
Home > User (with the weird path http://user/6)

when editing another user's profile tab the breadbrumb is:
Home > User (me) > User (the user i'm editing)

#3

locomo - August 22, 2009 - 19:01

i was just looking closer at the realname.module and i think this is where it creates breadcrumbs for user profiles:

/**
* Correct user page breadcrumbs.
*/
function realname_check_breadcrumbs($account) {
  $trail = array(l(t('Home'), ''));
  // If we are looking at someone other than the current user, fix the breadcrumb.
  if ($account->uid != $GLOBALS['user']->uid) {
    $trail[] = decode_entities(l($account->realname, '/user/'. $account->uid));
  }
  $trail = drupal_set_breadcrumb($trail);
}

does this code play well with custom_breadcrumbs?? is the leading slash before "user" part of the problem?

the behavior i'm seeing is that when logged in i see the correct breadcrumb trail for a different user.. but when not logged in the breadcrumb is incomplete (Home > John Doe rather than Home > Members > John Doe) and in addition the link to John Doe is of form http://user/6

thanks for any help!

#4

MGN - September 19, 2009 - 05:56

The leading slash before user does give rise to the double slash. I also get the double slash when using RealName, but the domain name is correct in my tests of the module.

RealName sets the breadcrumb for the user pages, custom breadcrumbs 6.x-1.x can only set breadcrumbs on nodes. So the two modules work well together, there is no conflict, but you can't set a custom user page breadcrumb either.

In custom breadcrumbs 6.x-2.x-dev, you can set a breadcrumb based on path (custom_breadcrumbs_paths). And you would be able to set the breadcrumb on user pages if RealName didn't. But since Realname is overriding the user pages, and there is no hook to allow another module to modify the breadcrumb, custom breadcrumbs can't do anything here. To get around this, you would need to hack RealName (just comment out the call to drupal_set_breadcrumb).

I hope this helps.

#5

Niels Hackius - November 1, 2009 - 12:13
Version:6.x-1.4» 6.x-2.x-dev
Status:postponed (maintainer needs more info)» active

Can you please provide some more information on how to make this work in Custom Breadcrumbs 2.x?

Settings

I have set pathauto to:
Pattern for user account page paths: -> people/[user-raw]
and am using views at people/ to display my users in a Grid.

Goal

Once I open people/mrsx I would like to set my breadcrumb to: Home >> People >> Mrs. X

Actual Behavior

I can achieve this behavior if I Add Custom Breadcrumb for Path:
I provide people/mrsx as Specific Path,
for Titles:
People
Mrsx

for Paths:
people
mrsx

Expected Behavior

I would like to provide people/* as Specific Path,
for Titles:
People
[user raw]

for Paths:
people
<pathauto>|[account-url]

Problems

  • Expected Behavior fails to provide any breadcrumbs. If I remove the * in Specific Path and provide a specific username, e.g. mrsx the breadcrumb will show my account - so it actually references to the logged in user.
  • The example in Actual Behavior fails when activating wildcards in the custom breadcrumb settings

#6

MGN - November 2, 2009 - 02:27

The tokens you are using refer to the logged in user, not to the user whose profile is located at that url.

There are a couple of ways to accomplish what you are looking for.

1. Create appropriate tokens using the TokenSTARTER.module (which comes with token) to return the information that you are looking for. You might also check to see if another contrib module already provides the tokens that you need and use it instead. If you can't find another contrib, its really not to hard to create your own tokens. I would really recommend this as a long term solution.

2. Use the 'allow php in breadcrumbs title and path' option, and write php code to get the titles and paths that you want.

Option 1 is safer, more transportable, and probably takes the most work.

There are also several ways for doing option 2. The most efficient is to use a template based breadcrumb (available in custom_breadcrumbsapi) on the module page user-profile.

Titles:

<?php
return array('titles' => array('People', $variables['account']->name), 'paths' => array('people', '/user/' . arg(1)));
?>

Leave the Paths section blank.

[You could also do a paths based breadcrumb on user/* (or people/*), but the php code required for this is a little more involved. The approach would be to grab the user id from the url, then use user_load to load the account so you have access to the account name. This would also work, but its more involved.]

#7

Niels Hackius - November 3, 2009 - 18:55

Hmm, actually I can't get this to work.
I decided for the "enable php" way to get started (before maybe writing a token-module)
Also for simplicity I decided to start out with path user/

Now what bugs me is this:

Specific path?
What does one provide for specific path? Maybe this can be made more clear, please?
I am not sure if one should put in one single path or if i can provide a directory. Like when I provide example/ will this work for anything above example or only for example?
Wildcards break everything
Lets say I specify "user/4" as specific path and for Titles I provide Team and in the next line Boss, for Path I provide team and in the next line team/boss. This works good.
Now when I turn on wildcards and change nothing else this stops working.

#8

Niels Hackius - November 9, 2009 - 10:28

MGN, can I provide anything else to help with this issue?

Or maybe can you provide pointers on how to debug this? I am willing to write a patch - just don't know on were to get started.

#9

MGN - November 9, 2009 - 20:08

The specific path should be a drupal path to some page on your site. Your example of 'user/4' could be a correct example. You can use a wildcards '*' for pattern matching (so user/* would also be valid).

I haven't been able to reproduce your report of 'wildcards breaking everything.' When you say it stops working, I assume you mean there is no custom breadcrumb at user/4 after you turn wildcard matching on?

Are you working with the latest code? If not, please update your code and be sure to run update.php.

#10

MGN - November 10, 2009 - 01:38
Status:active» postponed (maintainer needs more info)

#11

Niels Hackius - November 10, 2009 - 18:04
Status:postponed (maintainer needs more info)» active

Yes I do have the most recent code, but I figured out what the actual problem comes down to:

I have a rather rare setup for language: I always use the language prefix, even for the default language, so:

this: */user/* works, because the first * can be replaced by the language code, e.g. 'en' or 'de'. Its too bad that (this way at least) aliases are not processed - I have team set for an alias of user, and am using the username instead of the id - so it would be nice that if I specify */user/* the */team/* path would be processed as well (or vice versa)

It could be that this is by design, still I am setting this to active for a quick review - maybe its a bug after all.

#12

MGN - November 12, 2009 - 09:11

Aliases of custom breadcrumbs paths are not processed by design. This way, separate breadcrumbs can be defined for each path alias that you define for a given drupal path. This feature lets you tailor the breadcrumb according to the path alias that is used to access the page - So if you have pathalias-A and pathalias-B for some/page, you can easily setup three unique breadcrumbs. If you want the same breadcrumb structure for different aliases, I am afraid you have to set them up independently.

In this case, you could avoid the duplication by using the template-based breadcrumbs provided through custom_breadcrumbs api. Since both */user/* and */team/* would use the same template (user-profile).

#13

Niels Hackius - November 14, 2009 - 14:04
Status:active» by design

I just specified the two paths :-)

Thank you for the support - I was just confused by the option saying "All languages" and the text saying this would be taken care off..

#14

MGN - November 15, 2009 - 17:31
Category:support request» task
Assigned to:Anonymous» MGN

Great. When not using wildcards, the path prefix is dealt with automatically. I need to look into the code again and try to remember why the path prefix is not considered when wildcards are present. It might be that the code does need to be changed in this case, so I am marking this as a task until I can look into it further.

#15

MGN - November 15, 2009 - 20:22
Category:task» bug report
Status:by design» needs review

I did find a problem in the case when the breadcrumb language is set to 'All languages.' The current code incorrectly checks for /user/* (incorrect leading slash) when the breadcrumb language is set to all.

This patch seems to fix this problem. Can you try it out and see if it works as you would expect?

With this patch, you won't have to put in the first wildcard for the path prefix - you should just select 'all languages' instead.

AttachmentSize
520028_cb_paths_language_fix.patch 1.54 KB

#16

MGN - November 29, 2009 - 04:00
Status:needs review» fixed

I've commited the patch in #15 to 6.x-2.x-dev for further testing.

 
 

Drupal is a registered trademark of Dries Buytaert.