keithkelly
2 years agoLeader
Can I cache a component based on **parameter** ?
I have a component: <component id="example-component" category="foo"/>
<component id="example-component" category="bar"/>
<component id="example-component" category="baz"/> and I'd like...
- 2 years ago
Yes, the calls to setCacheVariations are at the wrong place as far as I understand the doc (Big caveat: I never used it myself, so just interpreting the docs). They state:
When you create custom variations of the markup cache:
- Create a wrapper component
- Define all variations in the wrapper component using componentCacheSupport
- Call the child component to be cached from within the wrapper component using the component directive
So you actually need two components:
- The wrapper component which sets the cache variation context object by calling something like the following (if you only include this component on a category page as in that case the node's id is the category id. If you want to include the component elsewhere you first need to Get ID of current category )
${componentCacheSupport.setCacheVariation("category_var", coreNode.id)}​
- Your actual component which gets cached and which just refers to that variation as you already have it shared in your
<@liaMarkupCache​>
🤞