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

rodibox’s picture

Component: files/upload data » Code
albelouw’s picture

I am getting exactly the same problem.

Any idea where we can fix this?

Thank You

albelouw’s picture

After 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

joergM’s picture

I am getting exactly the same problem.

CvW’s picture

Same problem for me, using 7.x-3.0-rc1

dawehner’s picture

Status: Active » Fixed

Sure 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.

CvW’s picture

I 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.

dawehner’s picture

@CvW
That's exactly what i wrote here:

[field_libropdf] itself is a link not only a url, so you should probably create a formatter which just returns the url.
albelouw’s picture

Thank you for the insight.

My problem is solved.

Albe

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

amirtaiar’s picture

I 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/

amirtaiar’s picture

Status: Closed (fixed) » Needs work
Tschet’s picture

I'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.

michaellenahan’s picture

Let'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).

miguered’s picture

I 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?

miguered’s picture

Worked adding relationship!, thanks CcW!! as said here: http://www.ewanhemingway.co.uk/blog/drupal-views-linking-file-path

alaa.ayyad’s picture

Component: Code » Views Data
Assigned: Unassigned » alaa.ayyad
Status: Needs work » Fixed

Hi,
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 !

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dcolburn’s picture

Issue 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.

matsbla’s picture

Version: 7.x-3.0-rc1 » 7.x-3.5

I 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.

matsbla’s picture

Version: 7.x-3.5 » 7.x-3.0-rc1

Oh, sorry, just wanted to say that I use 7.x-3.5

matsbla’s picture

Make 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

alaa.ayyad’s picture

Version: 7.x-3.0-rc1 » 7.x-3.5
Assigned: alaa.ayyad » Unassigned
Status: Closed (fixed) » Active

have you tried stes in comment #17 ?

eminencehealthcare’s picture

#8 Solved this for me.

Anonymous’s picture

Issue summary: View changes

#17 Solved too

jcodes.me’s picture

#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.

Kukulcan’s picture

I 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.

eboss’s picture

#17 worked!

DebakantMohanty’s picture

I had to change the Formatter to "URL to file" to make it workable!!

Kurt.j’s picture

Dude, #17 right on!

icebravo’s picture

#14 is ok for me. Using old versions

MustangGB’s picture

Category: Bug report » Support request
Status: Active » Fixed

Has been answered.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

anthonyroundtree’s picture

sorry did not mean to post question here