You can hide or disable elements (typically nodes or menu items) by using the item-active tag

You can specify multiple item-active tags, and all of them have to resolve to “active” in order for the element to be classified as active.

The item-active tag can specify either an sql query, a dbwql query or a “text” to be executed. This is done with a “sql”, “dbwql” or “text” tag.

(You can always add an “invert” tag set to true to flip the result.)
(inactive-mode can be “hide” or “disable”)

Dbwql “queries”

<menu-item>
	<item-active>
		<dbwql>$instance/is_readwrite</dbwql>
		<inactive-mode>disable</inactive-mode>
	</item-active>
	...
</menu-item>

The result from the query is parsed as follows:

A positive number Active
0 or a negative number Inactive
Empty result or empty string Inactive
A non empty result, that is not a number Active

SQL queries

If the sql query is a block you can add a “pl-sql” tag set to true.
If the query can potentially take a long time, you can add a “timeout” tag specifying the number of seconds to wait.

<menu-item>
	<item-active>
		<sql>select count(*) from sometable</sql>
		<pl-sql>false</pl-sql>
		<inactive-mode>hide</inactive-mode>
		<use-cache>true</use-cache>
	</item-active>
	...
</menu-item>

The result is parsed as:

A value of 0 Inactive
Everything else Active

Text “queries”

Text “queries” are a bit different.

They compare values that are resolved by other means than sql or dbwql (f.ex through menu selections, or based on the node you are on)

They specify a series of “cases” that are checked, and the first case to “hit” gives the result. If no cases hits, the result is considered “active” (unless you have added the optional “default” tag to change the default)

A case tag contains a value that will be checked. If the case also contains an “equals” tag, this is used for comparing. If there is no equals tag, any value except the empty string is considered a hit.

You do not have to specify both an “active” and “inactive” tag (usually you will just have one of them)

<item-active>
	<text>
		<default>active</default>
		<active>
			<case>
				<value>#ARG_OPTION_NAME#</value>
				<equals>Some name</equals>
			</case>
			<case>
				..
			</case>
		</active>
		<inactive>
			<case>
				<value>#ARG_OPTION_NAME#</value>
				<equals>Some other name</equals>
			</case>
			<case>
				..
			</case>
		</inactive>
	</text>
</item-active>

← Create Custom Extensions / Javascript property →

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Post Comment