How to add javascript quotation around string in typo3


 
Many time we need to add quote around the syntax. when we particularly work for js ( javascript ).

If you have syntax like : fileadmin/_processed_/csm_0001_2137573116.jpg”;

and you want to use this syntax in your javascript then we need some quotation around syntax.

for that following script will do the trick

$string = "fileadmin/_processed_/csm_0001_2137573116.jpg";

$quoteString = \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($string);

After print of that result Output will look like below

'fileadmin\x2F_processed_\x2Fcsm_0001_2137573116.jpg'

it will add addtional quote around the string.

I hope it will work for you πŸ˜‰ Njoy… πŸ™‚

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s