Impossibly to use block visibility php-code

edhel - December 2, 2008 - 07:02
Project:Node breadcrumb
Version:6.x-1.0-beta2
Component:Code
Category:bug report
Priority:normal
Assigned:edhel
Status:closed
Description

subj

#1

dynamind - March 2, 2009 - 16:09

This issue lacks a description, but I figure it concerns the same issue I was having:

It is impossible to use Block Visibility rules on nodes mapped by node_breadcrumb. This is true for the include/exclude paths and the PHP condition.

The reason is that the module changes the value of $_GET["q"]. In effect it fools Drupal's menu system in thinking it's actually showing a different page.

So when you try to determine the current node, it returns the node of the page it is attached to - not the node itself.

I could not wait for a general fix, so I hacked one myself.

Open the file node_breadcrumb.module and do the following change

function _node_breadcrumb_set_location(...) {
  $path = $_GET["q"]; // <-- add this line to store current path
  /* Normal code goes here untouched */
  $_GET["q"] = $path; // <-- add this line to restore current path
}

I hope someone finds this useful!

#2

edhel - March 11, 2009 - 04:15

dynamind, this code fix block visibility rules, but we lost menu location of nodes

#3

edhel - August 13, 2009 - 19:56
Status:active» fixed

fixed in beta3

#4

System Message - August 27, 2009 - 20:00
Status:fixed» closed

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

#5

brad bulger - October 22, 2009 - 19:14

it is still overwriting $_GET['q'] to be the last breadcrumb path. is that a by-design thing? it's turning up as a problem all over my theme code, which does things based on the current path. scratch that - i didn't realize that dev was older than the beta releases.

 
 

Drupal is a registered trademark of Dries Buytaert.