getContextValue(string key)¶
The getContextValue method is used to read back a value previously stored under the given key with
setContextValue. Stored values are shared across every module rendered within the
current page render, so a value set by one module instance is visible to getContextValue calls made by
any other module instance rendered on the same page.
Warning
In the Shoper Visual Editor (SVE), when a module using this method is dragged onto the canvas, its
initial render only has context of that module in isolation, not the full page — so
getContextValue/setContextValue may see incomplete or incorrect data at that point. Save the
layout and refresh the page to see these methods behave correctly with the full page context.
Input parameters¶
key¶
string The key to read. If a non-string value is passed, or no value has been stored under key, the
method returns null.
Returned value¶
The value previously stored with setContextValue (string, int, float or
bool), or null if nothing has been stored under key (or if key is not a string).