Sidebar

Using iTop

Creating your iTop

iTop Customization

"How to" examples
DataModel

User Interface

Automation & Ticket management

Portal Customization

:: Version 3.2.0 ::

Context Tags

Context Tags are a mean to provide information about the context (i.e. the call stack) to the PHP code being executed.

Context tags identifiers are just plain text strings. Context tags work as a simple stack, new tags can be pushed onto the stack by any piece of PHP code to indicate a specific context of execution.

To check if the current PHP code is being executed in a particular context, simply check the return value of the call ContextTag::Check('context-tag-identifier').

example.php
   if (ContextTag::Check('GUI:Portal'))
   {
       // Code to be executed only when performing a end-user action from the portal
   }

As of iTop 2.6, the following context tags are available (more can be added through extensions) :

  • Console, code: GUI:Console, correspond to the administration console
  • Portal, code: GUI:Portal, applies to all portals
    • <xxxx>, code: portal:<PORTAL_ID>, correspond to a specific portal instance, where xxxx is the label of that portal
    • Standard portal, code: portal:itop-portal, corresponds to the Standard iTop portal
  • Synchro, code: Synchro, applies to any synchro datasource
    • Synchro:<datasource_name>, applies to a specific synchro datasource (Not available on Trigger)
  • Setup, code Setup, applies during the iTop Setup processing.
  • CRON, code: CRON, applies to events triggered by the cron.php.
    • CRON:Task:<task_class_name>: A specific CRON task (Not available on Trigger)
  • REST, code:REST/JSON, applies on REST/JSON webservice calls
Since ContextTag works as a stack, several tags can be present in the stack at a given point of time. For example when the cron task CheckStopWatchThresholds is running, checking for either tags CRON or CRON:Task:CheckStopWatchThresholds will return true.
To find all the existing context tags in iTop, search for the string new ContextTag in the iTop code base.
If you want to add a new context tag onto the stack, simply call new ContextTag('your_tag_unique_identifier');.
3_2_0/customization/context.txt ยท Last modified: 2024/09/10 10:25 by 127.0.0.1
Back to top
Contact us