Hello people
In Drupal 7 I'm trying to rewrite the output of a field.
I want the output file is a link here.
With drupal 6 everything worked fine. Now when I put the path
adds a space to the file name
Show Rewrite results > Rewrite the output of this field > Link path
sites/drupal7conf/files/libropdf/[field_libropdf]
Replacement patterns
[field_libropdf] == Content: Libro Pdf
Resultado
sites/drupal7conf/files/libropdf/-blanck space- filename.pdf
And probe wicht
Remove whitespace
Is there a way to correct that mistake and delete the blank space that appears before the file name?
Any idea
Muchas Gracias desde ya.
Comments
Comment #1
rodibox CreditAttribution: rodibox commentedComment #2
albelouw CreditAttribution: albelouw commentedI am getting exactly the same problem.
Any idea where we can fix this?
Thank You
Comment #3
albelouw CreditAttribution: albelouw commentedAfter quite some time last night I found something that may assist the developers of this module. When you Put a tick in the Rewrite field it give you the problem as described.
But if you do not put it their, and you keep a tick in the Output this field as a link it creates the link 100%. So it appear when there is text or code in the Text area from Rewrite field it ads a space before the replacement pattern.
It appear that if it is a File field it is adding this space, but when it is a standard text field, it is displaying 100%.
Albe
Comment #4
joergM CreditAttribution: joergM commentedI am getting exactly the same problem.
Comment #5
CvW CreditAttribution: CvW commentedSame problem for me, using 7.x-3.0-rc1
Comment #6
dawehnerSure this happens if html as part of your output.
[field_libropdf] itself is a link not only a url, so you should probably create a formatter which just returns the url.
Comment #7
CvW CreditAttribution: CvW commentedI think the token [file_field] does not represent the path. In the module it is converted to an HTML link, which then is subsequently stripped of its tags, leaving the file name, prefixed with a space.
The solution is to get the token [file-path] in the field list of the view, and use that as link text in the rewrite of the title. Then is not needed to add /sites/default/files as prefix; it is all handled automatically.
In this page http://www.ewanhemingway.co.uk/blog/drupal-views-linking-file-path it is shown how to do it;
Make a relation to the file field embedded in the node, and then use the file path for the link.
Comment #8
dawehner@CvW
That's exactly what i wrote here:
Comment #9
albelouw CreditAttribution: albelouw commentedThank you for the insight.
My problem is solved.
Albe
Comment #11
amirtaiar CreditAttribution: amirtaiar commentedI was following the orders in that link and get mass url like:
bel/public%3A//projects/001.doc
this is the mass part - public%3A/
Comment #12
amirtaiar CreditAttribution: amirtaiar commentedComment #13
Tschet CreditAttribution: Tschet commentedI'm seeing variations of this on multiple views on multiple projects. They share few if any resources and are on multiple versions of Drupal 6 & 7. Filtering isn't a viable solution because these are often secondary fields. A list of names with links to additional information on some of them, etc. This sort of thing doesn't work when your link field is never null.
Comment #14
michaellenahan CreditAttribution: michaellenahan commentedLet's say we have a content type with a PDF file, and we want to link the body text of the node to the file.
In the view:
FORMAT: Show: Fields
FIELDS
Content: PDF file
Exclude from display: Checked
Formatter: URL to file
Content: Body
Rewrite the output of this field:
<a href="[field_pdf_file]">[body]</a>
Hope this helps.
Using the "URL to file" formatter is the key thing to remember.
PDF file will need to appear before the Body in the fields list (so that the [field_pdf_file] token is available to the Body).
Comment #15
miguered CreditAttribution: miguered commentedI have a problem with a photo file, i dont get a formatter for url to file straight, i´ve to choose rendered files and then use the link format, wich includes a icon for files before the filename.
And i get the space in the url, i suppose is a problem with the icon before the link in files rendered, any way around?
Comment #16
miguered CreditAttribution: miguered commentedWorked adding relationship!, thanks CcW!! as said here: http://www.ewanhemingway.co.uk/blog/drupal-views-linking-file-path
Comment #17
alaa.ayyad CreditAttribution: alaa.ayyad commentedHi,
Solution is in 'Formatter' of the field
I ran into same issue before and solved it like this:
- First, make sure the 'formatter' of the field is 'URL to file' not 'Generic File'.
- Then do your custom rewrite, and you can still use replacement patterns.
- Now tick 'Output this field as a link'.
- In the 'Link Path' put the replacement pattern of the file field ([field_libropdf] in your case).
- Tick 'Use absolute path'.
- Save and check result !
Comment #19
dcolburn CreditAttribution: dcolburn commentedIssue just cropped up for me trying to rewrite a View so a video preview thumbnail links to its external URL. It'd work too, except for %20 repeated 5 times at the leading edge of the output.
Comment #20
matsbla CreditAttribution: matsbla commentedI have the same problem. My field is 'URL to file' and I get 6 %20 in front of the url, and 2 at the end.
I also tested with the File force module http://drupal.org/project/file_force
When I put formatter to the field to "File force: url to file" i get the same %20-problem, and it also adds an extra "download=1" at the end of the url.
Comment #21
matsbla CreditAttribution: matsbla commentedOh, sorry, just wanted to say that I use 7.x-3.5
Comment #22
matsbla CreditAttribution: matsbla commentedMake sure that your link field is not using any custom wrappers or field templates, It should be set out as plain text:
http://drupal.org/node/1574640#comment-6738070
Comment #23
alaa.ayyad CreditAttribution: alaa.ayyad commentedhave you tried stes in comment #17 ?
Comment #24
eminencehealthcare CreditAttribution: eminencehealthcare commented#8 Solved this for me.
Comment #25
Anonymous (not verified) CreditAttribution: Anonymous commented#17 Solved too
Comment #26
jcodes.me CreditAttribution: jcodes.me commented#22 is the correct solution for this case as other solutions are specific on the situation.
my field is a plain text field on the content type and, also in the view, It is a plain text formatter and what i did is click on the field in the view and scroll down to style settings and UNCHECK the "use field template". thats it.
Comment #27
Kukulcan CreditAttribution: Kukulcan commentedI tried #17 doesn't work for me...until I found out I need to change the output to "URL to file" in the view, not in the display settings of the content type.
Comment #28
eboss CreditAttribution: eboss commented#17 worked!
Comment #29
DebakantMohanty CreditAttribution: DebakantMohanty commentedI had to change the Formatter to "URL to file" to make it workable!!
Comment #30
Kurt.j CreditAttribution: Kurt.j commentedDude, #17 right on!
Comment #31
icebravo CreditAttribution: icebravo commented#14 is ok for me. Using old versions
Comment #32
MustangGB CreditAttribution: MustangGB commentedHas been answered.
Comment #34
anthonyroundtree CreditAttribution: anthonyroundtree commentedsorry did not mean to post question here