Im setting a component in a custom page template like the following. This means that the nodeRef parameter will be set by url. Is it possible to set the nodeRef parameter by code dynamically?
thank you!
<sub-components>
<sub-component id="default">
<evaluations>
<evaluation>
<evaluators>
<evaluator type="config.component.evaluator">
<params>
<element>DocumentDetails/document-details/display-web-preview</element>
</params>
</evaluator>
</evaluators>
<url>/components/preview/web-preview</url>
<properties>
<nodeRef>{nodeRef}</nodeRef>
<api>api</api>
<proxy>alfresco</proxy>
<dependencyGroup>document-details</dependencyGroup>
</properties>
</evaluation>
</evaluations>
</sub-component>
Sure. In your example the /components/preview/web-preview is pointing to a web script. The web script has a controller (web-preview.get.js) and in that controller it grabs the nodeRef param and does something with it.
If you want to use a different nodeRef, you can extend that web script and enhance the logic accordingly.
For example, I recently needed to change the nodeRef that the previewer displays. Instead of showing the current node's content I wanted to show a related node's content. So I extended web-preview.get.js and changed the Alfresco.WebPreview widget instantiation to use the nodeRef that I fetched from an association instead of the nodeRef that was passed in.