Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
litespeed_wiki:cache:litemage:troubleshooting:javascript-global-var-problem [2016/05/06 14:11] Michael Alegre created |
litespeed_wiki:cache:litemage:troubleshooting:javascript-global-var-problem [2017/05/08 20:33] (current) Lisa Clarke |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== JavaScript global variable problem ====== | + | ~~NOTOC~~ |
+ | ====== Private Data Showing on Public Cache Content Due to JS Global Variable Issue ====== | ||
- | If a global variable in JavaScript is initialized based on user session data and saved in a public cache, then it will cause trouble for other users with differing session data. | + | ==== Problem ==== |
+ | Private data is showing on public cache content. | ||
- | As of version 1.0.2, a place holder block for JavaScript variables has been introduced. This place holder is a private block, so every user will get his/her own correct value. | + | ==== Cause ==== |
+ | Some global variables in JavaScript are initialized based on user session data but are saved in a public cache. | ||
- | Check the code: | + | ==== Solution ==== |
- | <code> | + | As of version 1.0.2, a place-holder block for JavaScript variables has been introduced. This place holder is a private block, so every user will get his/her own correct value. |
- | code/community/Litespeed/Litemage/Block/Inject/Jsvar.php | + | |
- | </code> | + | |
- | You can also write your own code to customize this block. Please be sure to keep a copy of your customized code in a local directory to avoid it being overridden during LiteMage updates. | + | Check the code: ''code/community/Litespeed/Litemage/Block/Inject/Jsvar.php'' |
- | You generally do not need to modify the block code and can instead just modify the template associated with that block. | + | ==== Extend ==== |
+ | You can also write your own code to customize this block. Please be sure to keep a copy of your customized code in a local directory to avoid it being overridden during LiteMage updates. | ||
- | <code> | + | You generally do not need to modify the block code and can instead just modify the template associated with that block: ''app/design/frontend/base/default/template/litemage/inject/jsvar.phtml'' |
- | app/design/frontend/base/default/template/litemage/inject/jsvar.phtml | + | |
- | </code> | + | |
For example: | For example: | ||
- | "isLoggedIn" is used by an SNS ajax cart for wishlists. In LiteMage's config.xml file located under magento_install_directory/app/code/community/Litespeed/Litemage/etc, this block, "litemage.jsvar", is listed under "welcome" and will be purged by logged_in/out events. | + | ''isLoggedIn'' is used by an SNS ajax cart for wishlists. In LiteMage's ''config.xml'' file located under ''magento_install_directory/app/code/community/Litespeed/Litemage/etc'', this block, litemage.jsvar, is listed under **welcome** and will be purged by logged_in/out events. |
- | If you have any other variables based on events not already represented in LiteMage's config.xml file, you can add them in as new blocks in the "esiblock" section. (Be sure to add a LiteMage ESI observer for these events as well) | + | If you have any other variables based on events not already represented in LiteMage's ''config.xml'' file, you can add them in as new blocks in the esiblock section. (Be sure to add a LiteMage ESI observer for these events as well) |