There are 2 questions.
1. In previous versions mp_file I changed the function mp_file_commit, adding:
$ new_name = $ node-> uid .'_'. $ node-> nid .'_'. $ sanitized_name .'.'. $ ext;"
Files renamed by this mask: uid_nid_nodename.ext. The latest version mp_file I could not get myself to repeat it. Could you help to repeat it?
2. I have already said that the use of Cyrillic characters file name is blank. I propose to add/change to mp_file after 285-line the following code:
/ / Rename file ...
if (module_exists ( 'transliteration')) (
$ transliterated = transliteration_get ($ title);
)
$ node_sanitized_title = preg_replace ('/[^ 0-9a-z \. \ _ \ -] / i ','', $ transliterated);
Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | keereel.zip | 541 bytes | syndicateStorm |
Comments
Comment #1
syndicateStorm commentedHi keereel, I'm on the verge of a 6.x production release, so this is a good time to get this incorporated. Let's see if we can get this and your other request(s) marked off as "fixed".
Unfortunately you will have to get the latest dev release (you might have to wait until this afternoon for it to come out) as I've made a few minor changes to help incorporate your request. Your request should now be supported by a new "hook" which will hopefully allow you to never have to make these changes again :-).
Do you have any custom modules you've written for your site? I typically have at least one called "site_helper" where I can put hooks and Drupal modifications, etc. If you need help setting one up I can help but you can probably find a lot of resources online which can help you figure this out.
In this "site_helper" module (or whatever you call it) paste in the following hook function:
If you leave the above code unmodified, mp_file should behave exactly the same. At this point you can modify this function to do what you want.
So here is some untested code that might work for you:
The above may not work and probably doesn't do exactly what you want. But hopefully it's enough to get you started. Let me know if I can help.
Comment #2
keereel> I'm on the verge of a 6.x production release.
This is good news. Thank you for the direction indicated, I will try to do it. All of my issues may be switched to the closed position, if it will facilitate release of the module. My questions are not so critical, that would delay the release, they can be resolved later.
Comment #3
keereelMaybe someone will find useful: I have done that to get the filename as uid_nid_filename.ext (all in mp_file.module):
line 289:
to
lines 313-314:
to
Is this correct?
Comment #4
syndicateStorm commentedkeereel, looks reasonable to me. However, I have a few thoughts:
* Sorry for making you download marketplace over and over, but make sure you have the Feb 14th release or later. I made a minor change specifically for you, that is included in that release and is consistent with post #1.
* I didn't test the code in #1 but you should be able to get the uid from the nid, right? Did you try that (see #1)?
* You should be able to do this all outside mp_file in your own custom module using hook_mp_file_name. I would imagine this would be preferable to editing mp_file.module unless you need faster execution or something? I think the second code snippet in #1 does almost everything you describe (it made need a little work but I think it's all there).
I look forward to hearing your thoughts. Cheers.
Comment #5
syndicateStorm commentedWell there is always something wrong with untested code :-). I used node_load($nid) but it should have been node_load($node_id). I have attached a custom module that does what you have requested. Here's all it is:
To use the attached module just put it in your modules folder and enable it just like you do any other module. Let me know how it goes.
Comment #6
keereelSorry for the delay. Dentist caught me, and he took all my time. I hope to soon get out of his hands and continue the experiments.
keereel.zip - it is site_helper module?
Comment #7
syndicateStorm commentedNo problem. Yes keereel.zip is site_helper. Although I changed the module name from "site_helper" to "keereel". You can change it back to site_helper if you want. Good luck.
Comment #8
keereelGreat, it works with #5 code in site_helper module! One more thing - in new_file_name we use file_name, but I think, node title is better. How can I make this?
Comment #9
syndicateStorm commentedGreat! Try $node->title.
Comment #10
3dloco commentedHello,
I noticed that you are modifying the code to rename files and I'd like to know whether you tried to use the filefield paths module to achieve this.
I am currently using filefield paths to rename, cleanup, and move files that are uploaded to the site. However, it is not working well with Marketplace. I noticed that renaming with filefield paths is ok for every CCK filefield except the one for Marketplace product files.
Is this something that needs to be configured/modified somewhere?
Thanks,
KH
Comment #11
syndicateStorm commented3dloco, interesting point. I'll take a look at the fielfield paths module and let you know what I learn. Thanks.
Comment #12
syndicateStorm commentedkeereel, I think we're done here? 3dloco, we can discuss fiefield paths here: http://drupal.org/node/724372.
Comment #14
keereelSomething changes in v.1.0.b1? My 'site helper' module (from #5) don't work now.
P.S. Is it possible to make field for 'filename' option with tokens in module configuration?
Comment #15
syndicateStorm commentedHey keereel, I believe the issue pertains to module weight. I had incorrectly set up the weighting system, but corrected it before releasing beta1. Make sure your module weight for site_helper is bigger than UC Marketplace. Let me know how it works for you.
Comment #16
keereelHi.
If MP have weight '0', I must just set weight '1' for my 'helper' module, right? In 'system' table..
Comment #17
syndicateStorm commentedThat should work. Did it? As long as MP < helper it should work. Basically the largest weight module will be executed last and will therefore have the last say on how the renaming should be done.
Comment #18
keereelyes, thank you!