Hello
Block only appears if the vocabulary id is smaller tant 9. When its greater than 9 (10, 11 etc...), the regex from preg_replace only return 1 number -the first one. For example, for vocabulary 11, preg_replace return 1 and then module thinks he has to add a block for vocabulary id 1 instead of 11.
For the moment i put
// Extract the vocabulary ID from the variable name
$vid = str_replace('taxonomy_blocks_vid_','', $result->name);
$vid = str_replace('_block_enabled','', $vid);
instead of
$vid = preg_replace('/(\w+)(\d+)(\w+)/', '$2', $result->name);
I'm very bad with regular expressions, can someone tell me what's the best way to rewrite it, instead of using str_replace ?
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 617186_taxonomy_blocks.module.patch | 749 bytes | giorgosk |
Comments
Comment #1
nyl_auster commentedMy changes are to put line 21 in taxonomy_blocks.module
Comment #2
nyl_auster commentedComment #3
opiI'll try :
$vid = preg_replace('/(\w+)_(\d+)_(\w+)/', '$2', $result->name);best,
opi
Comment #4
nyl_auster commentedThis code works wonderfully : this one should be commited if possible :-)
$vid = preg_replace('/(\w+)_(\d+)_(\w+)/', '$2', $result->name);Thanks Opi !
edit : could you explain me why the regex from the module is not able to catch two numbers, it seems correct to me... ( At least according to my poor acknowledges in regular expressions :-) ...)
Comment #5
opi@nyl_auster :
\w Match a "word" character (alphanumeric plus "_"), so (\w+)(\d+)(\w+) match any alphanumeric string, with a mandatory numeric inside !
with _(\d+)_, we're looking for a numeric string between 2 undescores.
Another regex that works is : ([a-z_]+)_([0-9]+)_([a-z_]+).
For further informations, have a look here : http://php.net/manual/fr/function.preg-replace.php
opi
Comment #6
giorgoskwhy are we trying to make this complicated ?
solution from comment 1 works
here is a patch, please apply and review
Comment #7
owahab commentedWorks for me, committed.