cancel
Showing results for 
Search instead for 
Did you mean: 

no spaces in content name

boneill
Star Contributor
Star Contributor
Hi All,

Is there any way to ensure that users do not enter spaces in the "Name" of the content they are creating when using a webform.  I would like to either prevent them from creating web pages with spaces in the page name or else replace the spaces with underscores "_".  Also is there any way of preventing them from using capitalisation for a web page name.

Regards
4 REPLIES 4

marcus
Champ in-the-making
Champ in-the-making
You can control the output of the renditions by changing the output path of the webform; you can use freemarker and some regular expression replacement techniques to replace the whitespace / other annoying characters.

Also, it might be better using hyphens as opposed to underscores; not sure if it's changed recently, but google at least still treats underscores as important characters, whereas dashes are treated for the most part as whitespace.

boneill
Star Contributor
Star Contributor
Hi Marcus,

I need to ensure that the xform file has no spaces in its name (ie xml with the values the user entered) not the renditions generated by transformations.  
you can use freemarker
.  Can you apply freemarker to the name of the xform file.  Have you any examples of this.

Thanks for your help.

marcus
Champ in-the-making
Champ in-the-making
The XML output name can be customised also, check the first step of the webform wizard. Something like


${name?lower_case?replace('[^a-z0-9.-_]+', '-', 'r')?replace('-+', '-', 'r')?replace('-+$', '', 'r')}.xml

should do what you're after.

boneill
Star Contributor
Star Contributor
Marcus,

Thanks for that.  Will try it out today.  I hope that you had a good honeymoon.