2

Is it possible to partially transliterate URL alias, so to leave for example the case of the node title unchanged, such as in:

/this/is/my/transliterated/path/THIS-IS-UNCHANGED-Node-Title-888

with the purpose behind it being to preserve product symbols, where similarity between lower and uppercase is unwanted.

And I mean fully automated behavior, such as with a template function or a module.

2

Certainly, you can call path_set_alias() (or path_save() in Drupal 7) and set up whatever you want. You could call these from within nodeapi() (or node_op..... in Drupal 7) and set up your path however you want. But, I also think that drupal isn't case sensitive, so, 'foo/bar/BAZ' is the same as 'foO/bAr/BaZ' as far as it's concerned here, so, gotta be careful.

ADDITION:

If you want pathauto to do this, quick hack would be to edit pathauto.inc and do this:

  if (true) {
    $foo=drupal_strolower(dirname($output));
    $bar=basename($output);
    $output=$foo . '/' . $bar;
  } else {
    // Optionally convert to lower case.
    if (variable_get('pathauto_case', 1)) {
      $output = drupal_strtolower($output);
    }
  }

where it does just this:

// Optionally convert to lower case.
if (variable_get('pathauto_case', 1)) {
  $output = drupal_strtolower($output);
}

but it's up to you to more refine if(true) otherwise it will do this for every alias.

| improve this answer | |
  • So if my Pathauto pattern is something like (a pseudo-code follows): [term-reference-alias]/[product-sku] and I would like to leave the SKU part as entered, shouldn't I rather invoke one of Pathauto functions? – Artur Mar 19 '12 at 10:12
  • you can go into pathauto's general settings and click the [ ] Leave case the same as source token values option and see what happens, but I thought your issue was that you wanted to make everything lowercase up to but not including the title of the node in the path, and, clicking this will do it in an all or nothing fashion. Of course, if there are no uppercase letters in '/this/is/my/transliterated/path' you will be ok. if not, you will need to do this aliasing yourself. – Jimajamma Mar 19 '12 at 15:12
  • Yes, I was perhaps unclear: I want Pathauto to take care of the path alias up to but excluding the last part. The last part should not be changed case-wise, just cleaned up punctuation-wise. – Artur Mar 19 '12 at 18:18
  • right, and pathauto does it for the entire alias, so it won't do it just for that component. you can do all of this yourself in a module, or, quick nasty hack, see addition above... – Jimajamma Mar 19 '12 at 19:46
  • Yep, gotta write own module for that. Tough life of a picky man... Thanks anyway. – Artur Mar 19 '12 at 20:49
0

I'm not familiar with Drupal, and I was just passing through.

Since case sensitivity and anti-similarity seems to be the primary goal, I'd imagine you could simply string break the URL in PHP with "/" as the division point as in the following code:

$arrayFullofURLPieces = explode("/",$originalURL,32);

You can do what you want with the pieces.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.