CGBetterForms- uploads with spaces
CGBetterForms- uploads with spaces
I installed CMSMS v2.2.11 and CGBetterForms v1.10.4 for a client website.
The form allows a visitor to fill in their information and upload a resume in PDF form to apply for listed jobs. The client gets and email notification with the form details and a link to the resume.
The process works perfectly unless the user has a space in the PDF file name. The space ends the link in the email to client and they are unable to retrieve the PDF.
My-Resume.pdf creates a link to clientsite.com/path/My-Resume.pdf. That works fine.
However, uploading My Resume.pdf creates a link to clientsite.com/path/My
Any suggestions on how to get rid of the space?
Thanks!
The form allows a visitor to fill in their information and upload a resume in PDF form to apply for listed jobs. The client gets and email notification with the form details and a link to the resume.
The process works perfectly unless the user has a space in the PDF file name. The space ends the link in the email to client and they are unable to retrieve the PDF.
My-Resume.pdf creates a link to clientsite.com/path/My-Resume.pdf. That works fine.
However, uploading My Resume.pdf creates a link to clientsite.com/path/My
Any suggestions on how to get rid of the space?
Thanks!
Re: CGBetterForms- uploads with spaces
You should be able to use |cms_escape:'url' on the filepath variable, so something like:
will convert my/path/to/file name.pdf to my/path/to/file%20name.pdf
Documentation for Smarty's escape is https://www.smarty.net/docsv2/en/langua ... ier.escape
Code: Select all
{$myfile|cms_escape:'url'}
Documentation for Smarty's escape is https://www.smarty.net/docsv2/en/langua ... ier.escape
Not getting the answer you need? CMSMS support options
Re: CGBetterForms- uploads with spaces
Great!
But where do I put this code? Where is the relevant filepath variable to change?
But where do I put this code? Where is the relevant filepath variable to change?
Re: CGBetterForms- uploads with spaces
I'm making some assumptions here without knowing your exact setup, but it should do the job. Open the form in CGBetterForms and go to the Handlers tab. One of them is likely an email handler, you can click on it and will see the template used to generate the email. Find the line that generates the link to the file and modify it there.
There are other options - you could rename the file on upload, or during/after form processing, but both of these would require some development knowledge. Encoding the link is probably the easiest.
There are other options - you could rename the file on upload, or during/after form processing, but both of these would require some development knowledge. Encoding the link is probably the easiest.
Not getting the answer you need? CMSMS support options
Re: CGBetterForms- uploads with spaces
thanks for the response and apologies for coming back to this so late. I tried as I understood your suggestion, but cannot get it working.
Installed CGBetterForms and used it fresh out of the box. Created an upload field named 'Resume' to upload resumes. No alterations of any kind to the code. Works perfectly when a PDF file is uploaded with no spaces at all.
to test your suggestion:
1. Went to the CGBetterForms--> the form--> Handlers--> email results to specified addresses
2. Converted {$Resume} line- which works fine for files with no spaces- and tried it as {$Resume|cms_escape:'url'}
It comes back with the full path, but with each special character marked up (spaces, colons, slashes, etc.).
Results also do not come back as a link, just comes back as a plain-text path.
3. Converted escape into a 'href=' but that does not work at all.
Any other suggestions? I feel like we are getting close.
Installed CGBetterForms and used it fresh out of the box. Created an upload field named 'Resume' to upload resumes. No alterations of any kind to the code. Works perfectly when a PDF file is uploaded with no spaces at all.
to test your suggestion:
1. Went to the CGBetterForms--> the form--> Handlers--> email results to specified addresses
2. Converted {$Resume} line- which works fine for files with no spaces- and tried it as {$Resume|cms_escape:'url'}
It comes back with the full path, but with each special character marked up (spaces, colons, slashes, etc.).
Results also do not come back as a link, just comes back as a plain-text path.
3. Converted escape into a 'href=' but that does not work at all.
Any other suggestions? I feel like we are getting close.
Re: CGBetterForms- uploads with spaces
Here is the email I get.
First result is a broken link.
Second result is plain text.
Third result does not show up as a link.
First result is a broken link.
Second result is plain text.
Third result does not show up as a link.
Re: CGBetterForms- uploads with spaces
The documentation for |cms_escape (which is just a customized version of Smarty's |escape) can be found here: https://www.smarty.net/docs/en/language ... escape.tpl
It's possible I just chose the wrong parameter, try urlpathinfo maybe.
It's possible I just chose the wrong parameter, try urlpathinfo maybe.
Not getting the answer you need? CMSMS support options
Re: CGBetterForms- uploads with spaces
Got it! Will play around with it. Thank you so much for pointing me in the right direction.
I do think, however, that the module should have this capability built in.
Thank you!
I do think, however, that the module should have this capability built in.
Thank you!
Re: CGBetterForms- uploads with spaces
After trying several different parameters to cms_escape, I still could not get this to work.
Added a bug report to the module, as this should come working out of the box anyhow.
Thanks for the help.
Added a bug report to the module, as this should come working out of the box anyhow.
Thanks for the help.
Re: CGBetterForms- uploads with spaces
In my opinion the module should return the actual value.
You as the website developer should then properly format it for your specific use.
BTW: note that some email clients try to properly create a link from a string looking like a link. You can't blame the module developer for the mail client failing that.
If you only want to replace spaces then I'd suggest to use
You as the website developer should then properly format it for your specific use.
BTW: note that some email clients try to properly create a link from a string looking like a link. You can't blame the module developer for the mail client failing that.
If you only want to replace spaces then I'd suggest to use
Code: Select all
{$Resume|replace:' ':'%20'}
Re: CGBetterForms- uploads with spaces
1. I am not blaming the module developer, I am just trying to solve a problem. It does attempt to create a link, but that link is truncated and, therefore, does not work with gmail or outlook.
This is not about blame at all, it is simply attempting to get it to work for my client. I use CGBetterForms on at least 5 sites and it works wonderfully. This is the first time I have had this request and problem.
2. {$Resume|replace:' ':'%20'} WORKED PERFECTLY!
Thank you!
This is not about blame at all, it is simply attempting to get it to work for my client. I use CGBetterForms on at least 5 sites and it works wonderfully. This is the first time I have had this request and problem.
2. {$Resume|replace:' ':'%20'} WORKED PERFECTLY!
Thank you!
Re: CGBetterForms- uploads with spaces
You could also do this to remove all spaces...
|replace:' ':''
|replace:' ':''