The $regex variable has impropper syntax and therefore no matches are made to any available paths on the site.

The patch provided fixes the problem.

Comments

Bèr Kessels’s picture

1) are you sure this is required. This code follows the blocks paths settings literally.
I am no rexexp guru, so if you can explain what you did, i would be very pleased.
Also: this patch does not apply

andremolnar’s picture

StatusFileSize
new1.01 KB

Bèr: I'm patching against CVS/contributions/modules/sections/sections.module

The first patches I made were just to get this working on my system:

I would not call myself a regex guru either but I have some experience writing and debugging short regex's like these.

The existing $regex created by the preg_match looked something like

/^(path)$/

which says - search for some substring [path] that is found just after the beginning of the string and just before the end

which does not match any URL.

I changed it to produce something like

/path/

which says - search for this string [path] anywhere in the larger string (url).

This DOES match if path is in the URL somewhere - BUT this is not perfect either (because 1) it is case sensitive and 2) the path used may be part of the domain name or part of a path which has a similar name (e.g. 'similarpath' or www.pathway.com)

This new patch builds a slightly better regex that produces something like
/^(http:\/\/)?.*\/path$/i

which says - search for zero or one occurrences of the substring http:// at the beginning of the string followed by any number of any type of carachters followed by a / followed by path which is just before the end of the string - and do this in a caes insenstive way.

NEXT I am going to debug the special case for which is currently not working properly.

andre

andremolnar’s picture

sorry that last line should say

NEXT I am going to work on the special case for <front> ...

andre

Bèr Kessels’s picture

wel,

I got it so far. But as said: I want to follow *exactly* the blocks regexp. that way the sections and blocks UI are consistant, and people need to invent only one set of regexps.

The blocks regexps use /^ $/ to bind the path to the beginning and end of the path, not use the full url. The other solution you give is a dirty hack (patch two), and will break on non clena urls AFAIKS.

Bèr

andremolnar’s picture

yes - patch two was dirty - but like i said I wrote it to meet the immediate need of getting it to work.

But - it would still work with clean URL's turned off (since the scope of the regexp is so broad).

I will be submitting another patch soon - I didn't to think to check patch 3 with clean url's turned off. patch 3 does not work *perfectly* with clean url's turned off - I will just need to change one character in the regexp.

I am going to investigate why the block module code works - and why your code wasn't working (it is exactly the same) before I submit another patch.

andre

andremolnar’s picture

StatusFileSize
new646 bytes

Sorry for wasting your time here - I figured out what the problem was.

The regular expression was not working in the function 'section_in_section' becasue the $base_url was out of variable scope.
that meant that the $url variable was not being set properly.

I was barking up the wrong tree - once I started printing out values the problem became clear.

This patch is very simple - one line to bring the $base_url into scope - the code then works properly in its original state.

The regular expressions I was building would work for a FULL url - not the partial $url which is set in this function (nor the $url which is set in block.module).

Looking at all this code now, do you think it would be wise for me to submit some patches to a) change the $url variable name to something more appropriate b) create a function in common.inc that replaces some code here and in block.module.

i.e.:

      $base = parse_url($base_url);
      $session = session_name() .'='. session_id();
      $url = str_replace(array($base['path'], '?'. $session), '', request_uri());
      $url = ereg_replace('^/(\?q=)?', '', $url);

andre

p.s. let me know if you have problems with the patch line breaks.

andremolnar’s picture

StatusFileSize
new630 bytes

update to patch file - this should work on *nix

andre

Bèr Kessels’s picture