We are using Rules to generate a custom breadcrumb trail. We're using Panels 3 and OG 6.x-2.0-rc3, the newest versions of Rules and Token.

We are able to create a Rule that generates a correct breadcrumb trail for Group Posts using the following settings:

Event: Content is going to be viewed
 Conditions: Content is a group post or a group
Action: Set Breadcrumb

In this scenario, we have everything we need to create the breadcrumb using Token, but only on GROUP POSTS, not on the GROUP HOME PAGE.

As has been mentioned in other posts, sometimes the breadcrumb doesn't work within Panels. The workaround here is to use the "System: User is going to view a page" event instead. This works fine, we're able to set the breadcrumb here. However, there are two problems:

1) only User-related tokens are available
2) We can't seem to limit this to just the page type that we are experiencing the problems on - Panels containing a Group home page.

I'm assuming nothing can be done about #1 because the variables we need are out of scope. So I think we can work around this by creating several rules, one for each content type, each with hardcoded breadcrumbs. However, we can't seem to limit this to just a single content type using a custom PHP test. (looking at $node->type doesn't work because it's out of scope here).

So how would we go about limiting a rule to a specific content type when using the "System: User is going to view a page" event?

Comments

friolator’s picture

I solved this by resorting to a node_load() in the php evaluation, then testing for the content type. If there's a more efficient way to go about this, please let me know.

crea’s picture

That event is broken, I would not recommend using it. See #393528: Rules hook_init() causes theme system to initialize too early

friolator’s picture

ugh. thanks. actually, this explains the bizarre block admin behavior i've been seeing for the past few days.

So, if I read that thread correctly, would I be safe setting the breadcrumb in some custom PHP code, rather than using a preset action in Rules? or is that going to cause the same problems? (I'm not really that familiar with the internals of drupal, so I don't know if it'll be a problem).

thanks!

crea’s picture

I think to be 100% sure, unless you want to dig deep into code, you should avoid using this event for ANY output (and setting breadcrumb is output). Or wait till Fago looks at that issue, and posts his opinion about it. Maybe in future this event will be limited or disabled completely, I dunno..

friolator’s picture

hmm. that sucks.

In the mean time, is there any other way for me to deal with this issue - we're using Panels, and as such, this is the only way I'm aware of to set the breadcrumb so that it appears on the panels page. We're scheduled to go into beta with our site in the next couple of weeks, so I really need to get something worked out.

crea’s picture

I think you can set breadcrumb using custom PHP code in Panel pane (or better make custom block or CTools content type). I know it's probably ugly but it worked fine for me in Drupal 5.x. Perhaps there are also modules that could do that job for you.

friolator’s picture

ok. looks like the way I'll handle this is with some code that generates a custom breadcrumb trail in a mini-panel that's included wherever we need a breadcrumb.

thanks for the help!

fago’s picture

Status: Active » Fixed

Use the "Content is being viewed" event when you need the node.

friolator’s picture

Unfortunately, this wasn't an option for us in most of the cases. It works fine when viewing a node, but on things like a View-generated index of categories, it doesn't work. We ended up making a small module to generate breadcrumbs, and we're just calling it from Panels, rather than doing it with Rules.

crea’s picture

It's same old problem: there's poor Rules-Panels cooperation. Perhaps some new event like "Panel Page is going to be viewed" is needed, that would finally make the bridge between two.

crea’s picture

Title: "User is going to view a page" - how to limit by content type? » New "Panels page is going to be viewed" Rules event
Project: Rules » Panels
Version: 6.x-1.0 » 6.x-3.x-dev
Component: Miscellaneous » Code
Category: support » feature
Status: Fixed » Active

Well if it can be fixed, it should be in CTools or Panels, not Rules.
For example, we need that event to use any actions that invoke theming functions ( as stated in #393528: Rules hook_init() causes theme system to initialize too early, "user is going to view a page" event is not suited for output since it's invoked in hook_init() )

merlinofchaos’s picture

Status: Active » Fixed

I provided an alter hook for custom breadcrumbs. Presumably rules could use it too.

Try hook_ctools_render_alter($info, $page, $args, $contexts, $task, $subtask)

Status: Fixed » Closed (fixed)

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