I see this is a few months old, but I wanted to jump in since I've spent the better part of a day trying to do the same exact thing.
Ultimately, here is what I ended up using as my Visibility condition (found under Element restrictions on the General tab):
System.GetObject("cms.node",Convert.ToInt(QueryString.nodeid, 0)).NodeClass == "Intranet department"
In my case, I only wanted this tab visible to pages that were "IntranetPortal.Department" pages. So replace Intranet department
with the display name (not the code name!) of the class you're looking for.
So this works. But it doesn't particularly feel right to me. I was at least hoping to use the class name (code name), and not the display name. But I couldn't figure out any way to get that.
Some additional notes/info on how I figured this out:
It seems that UIContext.EditedObject
and UIContext.EditedObjectParent
are null in this context. And if you follow the tree up and look in the Properties tab of each of the parent nodes ("Edit", "Pages") you can see that Object type and Parent Object Type are not set. Which is (I think!) where those UIContext
properties come from. CurrentDocument
is null as well.
UIContext.Data
seems to hold some relevant information, but I couldn't figure out exactly what, and exactly how to access some of it. Which sounds rather strange so let me explain: I was using the Object listing page template for my UI element. In the Properties tab there is a Header text field that allows macros. So I was really just blindly testing the values of various objects using this field, and refreshing that tab in another browser window to see what it produced. This is how I know CurrentDocument
, UIContext.EditedObject
, and UIContext.EditedObject
parent are all null. If I entered {% CurrentDocument ?? "(null)"%}
in here, the header text would produce "(null)".
So when I entered {%UIContext.Data|(identity)GlobalAdministrator%}
as a value, it spit out a string that included the underlying QueryString values, but also some other properties that I couldn't figure out how to access. The module name was in there. As was the object type (I think?). I don't really. I eventually gave up and went with the method above, because I didn't want to waste any more time poking around here.
In the end, I'm convinced there must be a much easier way to do this. But I don't know what it is. So if anyone has some insight here, I'd love to hear it.