2022.2
Table Of Contents
- Welcome to PrintShop Mail Connect 2022.2
- Setup And Configuration
- System and Hardware Considerations
- Installation and Activation
- Preferences
- Clean-up Service preferences
- Database Connection preferences
- Editing preferences
- Email preferences
- Emmet preferences
- Engines preferences
- Hardware for Digital Signing preferences
- Language preferences
- Logging preferences
- Parallel Processing preferences
- Print preferences
- Sample Projects preferences
- Save preferences
- Scripting preferences
- Versioning preferences
- Engines preferences
- Parallel Processing preferences
- Known Issues
- Uninstalling
- General information
- Versioned projects
- The Designer
- Designer basics
- Content elements
- Snippets
- Styling and formatting
- Personalizing content
- Variable data in the text
- Conditional content
- Dynamic images and Print section backgrounds
- Snippets
- Scripts
- Loading data
- Variable data in text: expressions
- Variable data in text: scripts and placeholders
- Formatting variable data
- Showing content conditionally
- Conditional Print sections
- Dynamic images
- Dynamic Print section backgrounds
- Handlebars in OL Connect
- Preferences
- Clean-up Service preferences
- Database Connection preferences
- Editing preferences
- Email preferences
- Emmet preferences
- Engines preferences
- Hardware for Digital Signing preferences
- Language preferences
- Logging preferences
- Parallel Processing preferences
- Print preferences
- Sample Projects preferences
- Save preferences
- Scripting preferences
- Versioning preferences
- Writing your own scripts
- Script types
- Creating a new Standard Script
- Writing a script
- Setting the scope of a script
- Managing scripts
- Testing scripts
- Optimizing scripts
- The script flow: when scripts run
- Selectors in OL Connect
- Loading a snippet via a script
- Loading content using a server's API
- Using scripts in Dynamic Tables
- Control Scripts
- Post Pagination Scripts
- Translating templates
- Designer User Interface
- Designer Script API
- Generating output
- Print Manager
- PrintShop Mail Connect Release Notes
- OL PrintShop Mail Connect Release Notes 2022.2.3
- Previous Releases
- OL PrintShop Mail Connect Release Notes 2022.1.5
- OL PrintShop Mail Connect Release Notes 2021.2.1
- OL PrintShop Mail Connect Release Notes 2021.1
- OL PrintShop Mail ConnectRelease Notes 2020.2.1
- OL PrintShop Mail Connect Release Notes 2020.1
- OL PrintShop Mail Connect Release Notes 2019.2
- OL PrintShop Mail Connect Release Notes 2019.1
- PrintShop Mail Connect Release Notes 2018.2.1
- PrintShop Mail Connect Release Notes 2018.1.6
- PrintShop Mail Connect Release Notes 1.8
- PrintShop Mail Connect Release Notes 1.7.1
- PrintShop Mail Connect Release Notes 1.6.1
- PrintShop Mail Connect Release Notes 1.5
- PrintShop Mail Connect Release Notes 1.4.2
- Knowledge Base
- Legal Notices and Acknowledgements
Inthisexample,@product@isapattern(tobeusedinasearch)andgisamodifier(tofindall
matchesratherthanstoppingafterthefirstmatch).Formoreinformationaboutpossibleregular
expressions,seehttps://www.w3schools.com/js/js_regexp.asp.
Replaceseveralplaceholdersinonescript
Supposethereare20differentplaceholdersinapostcard(fortheaddress,accountandcustomer
details,apromocode,theduedate,discounts,alinktoapersonalizedlandingpageetc.).Typicallythis
wouldrequire20queries.EvenafteroptimizingthesescriptsbyusinganIDasselectorforthose
scripts,therearestill20scripts,20queriestorun.
Iftherewasonlyonequery,onesinglescripttodoallthework,theoutputcouldbegeneratedmuch
faster.Reducingthenumberofscriptsimprovestheperformanceofthetemplate.Howtodothis?
First,wrapthecontentthatcontainsalloftheplaceholdersinone(inline)BoxandgivethatBoxor
SpananID(ontheAttributespane).Next,createascriptthatusesthatIDasselector.Thenreplaceall
placeholdersinthescriptandputthecontentbackinthetemplate.
Thisissimilartoworkingwithsnippets,butinthiscasetheelementisextractedfromtheactualtem-
plate.
Example: Thefollowingscriptreplacesalloftheplaceholdersonapostcard.Ittakesadvantage
oftheJavaScriptreplace()command.AssumingthattheIDoftheblockthatrequiresper-
sonalizationispromoblock,thescripthastohaveitsselectorsetto#promoblock.
var block = results.html();
var data = record.fields;
block = block.replace('@name@',data.first + ' ' + data.last);
block = block.replace('@address@',data.address);
block = block.replace('@zip@',data.zip);
block = block.replace('@city@',data.city);
block = block.replace('@country@',data.country);
block = block.replace('@saldo@',data.saldo);
block = block.replace('@promo@',data.promo);
block = block.replace('@customercode@', data.customercode);
…
results.html(block);
ThefirstlineretrievestheHTMLofthepromoblockandstoresitinavariablecalledblock.Tomakethe
codemorereadible,thefieldsfromtherecordarestoredinavariablenameddata.Afterreplacingthe
placeholdersbyvalues,thescriptreplacestheHTMLofthepromoblockwiththepersonalizedstring.
Otherresources
TherearealsomanyresourcesonlinetohelplearnaboutJavaScriptperformanceandcodingmis-
takes.Seeforexample:
l
JavaScriptperformance
l
The10mostcommonJavaScriptmistakes
Page 383










