Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • John 88 posts 112 karma points
    Jul 21, 2011 @ 08:52
    John
    0

    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

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 21, 2011 @ 10:11
    Dirk De Grave
    0

    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?

    var doc = new Document(id) //id is passed through the querystring
    var myOtherVar = doc.getProperty("alias").Value;

    Hope this helps.

    Regards,

    /Dirk

  • John 88 posts 112 karma points
    Jul 21, 2011 @ 11:44
    John
    0

    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.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 21, 2011 @ 12:08
    Dirk De Grave
    0

    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

  • John 88 posts 112 karma points
    Jul 21, 2011 @ 12:53
    John
    0

    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?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 21, 2011 @ 13:00
    Dirk De Grave
    0

    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

  • John 88 posts 112 karma points
    Jul 22, 2011 @ 01:27
    John
    0

    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:

    1. Retrieve the document for the current node, the ID passed via the querystring
    2. Look at the Path property, split it by commas and retrieve the document for the node at path position X
    3. 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

Please Sign in or register to post replies

Write your reply to:

Draft