I was looking at the tokens that are now available to expand the file upload path and they all seem to only gear toward basing it on user data.

It would be great to have it also focus on node data. [nid] and [node-title] would be a great asset!

CommentFileSizeAuthor
#5 filefield.module.patch798 bytesricflomag

Comments

jpetso’s picture

Version: 5.x-2.0 » 5.x-2.2
Status: Active » Postponed (maintainer needs more info)

I was told that node data cannot be used as this stuff also happens when the node is not known or does not yet exist. Or something like that... heard that at a time when I didn't know much about Token, it would be neat if someone could verify or deny if this is doable (from a coding point of view) with CCK file uploads. Perhaps I'll find out by myself. I think it might work, but then again dopry should have known why he did it that way... right?

dopry’s picture

I try to only use fixed data for tokens... using transient data is a recipe for problems, but static paths are stores in the db... I'm not going to do this for now though until I can spend time making sure it works.

baja_tz’s picture

subscribe

dopry’s picture

Version: 5.x-2.2 » 6.x-3.x-dev
Status: Postponed (maintainer needs more info) » Active

bumping version..

ricflomag’s picture

StatusFileSize
new798 bytes

Here is a very simple 2 lines patch to provide node tokens. I use it to have a node-specific folder where files are uploaded. Hope it helps.

ricflomag’s picture

Status: Active » Needs work
steingard’s picture

This is great, however I am finding that the first file gets saved into the "files" root, and then subsequent files get saved into the folder based on the [nid]. I then have to go back into the node, delete the first file, save it, edit and upload the first file again for it to fall into place properly.

Any idea how to get around this.

A friend said that maybe I need to adjust the weight of where the module process occurs in the saving procedure in the database (I was a bit confused, but kinda get it... does this make sense?).

ricflomag’s picture

@steingard: This is possibly a workaround indeed, as the home made module i'm coding and that uses this patch without problems has its weight greater than 0. I don't know though how we could better the patch so that it wouldn't be necessary to do this.

Anyway, if you want to try to change the weight of the module that uses token, be cautious because it might have side effects (as other things will probably change their order of execution).

brunodbo’s picture

I would love this: it would make it possible to set up file paths like 'CCYY/MM/DD' (those tokens being replaced with the node's create info) instead of just dumping everything straight into '/files'.

dopry’s picture

Status: Needs work » Closed (fixed)

no I'm afraid I'll be foregoing node tokens. If you want more generic date tokens... poke eaton the token module maintainer. or write up the tokens yourself... There is even a patch in the token queue you can totally use.

brunodbo’s picture

Ok. I'll try using [site-date] first. That might work as well.

brunodbo’s picture

Hmm, the [site-date] token seems to be not so handy for my purpose after all. These ones are though.

deciphered’s picture

Have a working option for this at: #280704: node tokens revisted