Firstly, thanks for a great module!
I have a case where I would like for the file path stored location inside my files directory [sites/default/files
] to be different then the url alias the user will see.
Expected behavior I would have liked was for the URL the users see when the file is served to them sitedomain.com/category/filename.pdf
and the actual file is stored at sitedomain.com/sites/default/files/pdf/category/filename.pdf
. However when setting these in the file field path settings I'm getting the drupal error "The requested page .. could not be found."
If I set the file path and file alias settings to both include the pdf/
in the beginning of the path like the following then the file gets served as expected.
File Path: pdf/[node:field-category:url:relative]
.
File Alias: pdf/[node:field-category:url:relative]/[file:ffp-name-only-original].[file:ffp-extension-original]
Then the file gets served as expected at sitedomain.com/pdf/category/filename.pdf
The module seems to only take care of allowing one to create an alias that the user won't see the sites/default/files/
directory structure in the url path but any other folder paths created inside that directory needs to be displayed in the alias as well. Is there a way we can set that to not be the case?
Steps to reproduce issue:
- install the following modules file_aliases, filefield_paths, token and any dependent modules
- create a term vocabulary called "pdfs" with two terms
- create CT with a category term reference type field to reference the above created vocabulary terms in this content type with the select option
- add a file upload field
- set the file path settings in the file field settings to pdf/[node:field-category:url:relative]
(insert correct 'field-category' token for the category field that was created above)
- set the path alias settings to [node:field-category:url:relative]/[file:ffp-name-only-original].[file:ffp-extension-original]
- create a piece of content in that content type and upload a pdf file
- choose a term/category from the category field
- once viewing the node with the file displayed on it try to open the file
- I get the standard drupal error "The requested page .. could not be found."
Comment | File | Size | Author |
---|---|---|---|
file-field-settings-screenshot.png | 136.54 KB | hershey.k |
Comments
Comment #2
hershey.k CreditAttribution: hershey.k commentedComment #3
hershey.k CreditAttribution: hershey.k commentedComment #4
hershey.k CreditAttribution: hershey.k commentedClarifying issue.
Comment #5
hershey.k CreditAttribution: hershey.k commentedComment #6
hershey.k CreditAttribution: hershey.k commentedComment #8
Deciphered CreditAttribution: Deciphered commentedIs fixed and committed... although tests are failing on Drupal.org, so possibly still needs work.
The issue was/is that the token you where using was putting a forward slash at the from of the alias (it was a relative URL after all) where the Path Alias system doesn't work with a forward slash at the starts (even though it lets you have it). The solution is simply to cleanup the alias after it's processed, which is done and committed.