By amir simantov on
The Pathauto generates an alias according to the title of the item. Rather, I would like it to generate a random number (or number + letters), so the user gets url as:
- mydomain.com/k57js
- mydomain.com/9wn71
etc.
I was searching for such a module or code snippet, but could not find one. Any ideas where to look for or how to do it myself?
Thanks!
Comments
Use CCK Computed Field to
Use CCK Computed Field to generate a random text string. It will require a few lines of PHP coding.
Pathauto will offer a token that you can use that will put the contents of that Computed Field into the URL. Don't worry about checking for duplicates... Pathauto will take care of that for you, and add an extra "_0", "_1", "_2", etc. if needed.
-Corey
How to use the computed field then as part of the URL?
Thanks Corey. Where should I then put the php code and what should it be? Any reference or snippet?
Thanks again!
BTW - Are there any other ways to accomplish the task except using CCK?
Done! Thanks Corey!
And here is the function I have used:
Why?
Just out of curiosity. Why do you need/want to do this? You could just use the node id, which is available in pathauto straigh away if you do not want a long string of characters.
It looks to me that you are complicating your life and your users' to some extent.
And by the way, random does not mean unique, although I think pathauto will avoid a second path with the same "random" combination, I'm not 100% sure it'll do; it might depend on how you implement this.
This is for privacy reasons
I do not want people which don't have a specific link to browse for content by node id. This will not prevents bots, but it is private enough.
Makes sense
I knew there was a reason.
:-)
Is it OK for you using a running number by node type instead of using node id as I suggested? If so, there's a module for that already:
http://drupal.org/project/type_local_nids
Hope that helps.
Also ...
http://drupal.org/node/105049
Although that's for D5.
Thanks but no
It actually helps users track the nodes in my situation...