Hello. I have my custom content menu item setup and working (v4.7, IAction implementation). My JS function, however, needs 2 variables. The first is the node id which I can retrieve using UmbClientMgr.mainTree().getActionNode().nodeId but the second varibale is a property value within an ancestor of the current node. Is there any way to I can use a variable with IAction? Or is there an appropriate JS function within UmbClientMgr.mainTree() or UmbClientMgr.mainTree().getActionNode() that'll allow me to query a different nodes property?
why would you pass the additional variable if you already pass the id of the current node for which your context menu item was clicked? I assume you'd want to show a modal dialog or execute some custom code. So, it should be pretty straightforward to get that info based on the id passed instead of passing it via the querystring?
var doc = new Document(id) //id is passed through the querystring var myOtherVar = doc.getProperty("alias").Value;
Hey Dirk, thanks or the reply. My reasoning for wanting to pass the variable is because I'll already have the variable when processing the menu. The property is on a parent node, a number of nodes up the tree and doing a document.parent 10 times is a lot more DB calls than I want. Unless there's a way to parse up the tree without a db call each time? It can't be nodes either as the elements may be unpublished.
Ok, I see your point... but, even if you'd like to pass the variable via qeurystring, you'd still need to look up the variable from a ancestor node, and you'll have to hit the db anyway... so, in that case, it won't make a diff if you look up the info and set it as extra param on the querystring of your context menu item or fetch it when a user clicks on the menu item.
No sorry I should explain more. The property value is used in an external application, so once the user clicks the menu item a new window is opened with the node id and this other variable. No other ancestor lookup would be needed.
I know using the Document object causes a DB hit everytime. Does CMSNode also cause a DB hit? Or Node?
Ok, in that case you're doomed to hit the db using the document api to fetch data from other doc's in case you need info from unpublished nodes or nodes which have recent changes that weren't published yet, otherwise you can use the nodeFactory.Node class (only published info)
And yes, document IS a cmsnode, so you'll hit the db for both of the objects
Alright thanks Dirk. It ended up being not so bad in the end.
On the second page I know the node id and I know the tree position of the second node I'm interested in (one below the root). So what I ended up doing was:
Retrieve the document for the current node, the ID passed via the querystring
Look at the Path property, split it by commas and retrieve the document for the node at path position X
Query the property on the above node.
Means 3 DB hits that I was hoping to avoid but it's better than double or triple that if I had to continually check Document.Parent
Custom context item (pt 2) and variables
Hello. I have my custom content menu item setup and working (v4.7, IAction implementation). My JS function, however, needs 2 variables. The first is the node id which I can retrieve using UmbClientMgr.mainTree().getActionNode().nodeId but the second varibale is a property value within an ancestor of the current node. Is there any way to I can use a variable with IAction? Or is there an appropriate JS function within UmbClientMgr.mainTree() or UmbClientMgr.mainTree().getActionNode() that'll allow me to query a different nodes property?
Cheers
Hi John,
why would you pass the additional variable if you already pass the id of the current node for which your context menu item was clicked? I assume you'd want to show a modal dialog or execute some custom code. So, it should be pretty straightforward to get that info based on the id passed instead of passing it via the querystring?
Hope this helps.
Regards,
/Dirk
Hey Dirk, thanks or the reply. My reasoning for wanting to pass the variable is because I'll already have the variable when processing the menu. The property is on a parent node, a number of nodes up the tree and doing a document.parent 10 times is a lot more DB calls than I want. Unless there's a way to parse up the tree without a db call each time? It can't be nodes either as the elements may be unpublished.
Ok, I see your point... but, even if you'd like to pass the variable via qeurystring, you'd still need to look up the variable from a ancestor node, and you'll have to hit the db anyway... so, in that case, it won't make a diff if you look up the info and set it as extra param on the querystring of your context menu item or fetch it when a user clicks on the menu item.
Cheers,
/Dirk
No sorry I should explain more. The property value is used in an external application, so once the user clicks the menu item a new window is opened with the node id and this other variable. No other ancestor lookup would be needed.
I know using the Document object causes a DB hit everytime. Does CMSNode also cause a DB hit? Or Node?
Ok, in that case you're doomed to hit the db using the document api to fetch data from other doc's in case you need info from unpublished nodes or nodes which have recent changes that weren't published yet, otherwise you can use the nodeFactory.Node class (only published info)
And yes, document IS a cmsnode, so you'll hit the db for both of the objects
Cheers,
/Dirk
Alright thanks Dirk. It ended up being not so bad in the end.
On the second page I know the node id and I know the tree position of the second node I'm interested in (one below the root). So what I ended up doing was:
Means 3 DB hits that I was hoping to avoid but it's better than double or triple that if I had to continually check Document.Parent
is working on a reply...