• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: CGBetterForms- uploads with spaces
PostPosted: Wed Jun 10, 2020 3:51 pm 
Offline
Forum Members
Forum Members

Joined: Fri May 22, 2015 4:35 pm
Posts: 16
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!


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterForms- uploads with spaces
PostPosted: Wed Jun 10, 2020 8:10 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Feb 25, 2009 4:25 am
Posts: 968
Location: Victoria, BC
You should be able to use |cms_escape:'url' on the filepath variable, so something like:
\$1:
{$myfile|cms_escape:'url'}

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/language.modifier.escape

_________________
Not getting the answer you need? CMSMS support options


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterForms- uploads with spaces
PostPosted: Fri Jun 12, 2020 2:51 pm 
Offline
Forum Members
Forum Members

Joined: Fri May 22, 2015 4:35 pm
Posts: 16
Great!

But where do I put this code? Where is the relevant filepath variable to change?


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterForms- uploads with spaces
PostPosted: Fri Jun 12, 2020 2:59 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Feb 25, 2009 4:25 am
Posts: 968
Location: Victoria, BC
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.

_________________
Not getting the answer you need? CMSMS support options


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterForms- uploads with spaces
PostPosted: Thu Jun 25, 2020 2:34 pm 
Offline
Forum Members
Forum Members

Joined: Fri May 22, 2015 4:35 pm
Posts: 16
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.


Attachments:
Screenshot- Handlers.jpg
Screenshot- Handlers.jpg [ 130.3 KiB | Viewed 204 times ]
Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterForms- uploads with spaces
PostPosted: Thu Jun 25, 2020 2:37 pm 
Offline
Forum Members
Forum Members

Joined: Fri May 22, 2015 4:35 pm
Posts: 16
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.


Attachments:
Screenshot- results.jpg
Screenshot- results.jpg [ 81.62 KiB | Viewed 202 times ]
Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterForms- uploads with spaces
PostPosted: Thu Jun 25, 2020 2:41 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Wed Feb 25, 2009 4:25 am
Posts: 968
Location: Victoria, BC
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.modifier.escape.tpl

It's possible I just chose the wrong parameter, try urlpathinfo maybe.

_________________
Not getting the answer you need? CMSMS support options


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterForms- uploads with spaces
PostPosted: Thu Jun 25, 2020 2:57 pm 
Offline
Forum Members
Forum Members

Joined: Fri May 22, 2015 4:35 pm
Posts: 16
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!


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterForms- uploads with spaces
PostPosted: Fri Jun 26, 2020 6:22 pm 
Offline
Forum Members
Forum Members

Joined: Fri May 22, 2015 4:35 pm
Posts: 16
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.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterForms- uploads with spaces
PostPosted: Fri Jun 26, 2020 6:51 pm 
Offline
Dev Team Member
Dev Team Member

Joined: Mon Nov 28, 2011 9:29 am
Posts: 3214
Location: The Netherlands
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

\$1:
{$Resume|replace:' ':'%20'}


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterForms- uploads with spaces
PostPosted: Fri Jun 26, 2020 7:06 pm 
Offline
Forum Members
Forum Members

Joined: Fri May 22, 2015 4:35 pm
Posts: 16
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!


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: CGBetterForms- uploads with spaces
PostPosted: Fri Jun 26, 2020 9:19 pm 
Offline
Administrator
Administrator
User avatar

Joined: Thu Mar 09, 2006 5:32 am
Posts: 12674
Location: Arizona
You could also do this to remove all spaces...

|replace:' ':''

_________________
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
$1


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Hosting Nation - Managed CMSMS Hosting