Constants you can use in your Organizer SQL

When you are writing fragments of SQL in TUIX tags for use in Organizer, you may include the value of constants defined in PHP using the syntax:

[[CONSTANT_NAME]]

The following constants are provided for Organizer. The constants provided here are all escaped and have quotes placed around them if needed:

[[ADMIN_ID]]

The ID of the current Admin.

[[COMBINE_ITEM]]

When using the <combine_items> tag a constants called [[COMBINE_ITEM]] is available in select mode. This lets you access the id of the previously selected item.

(As with the other constants here, this will be escaped with quotes placed around it. You can use theCOMBINE_ITEM__NO_QUOTES constant instead if you need to access the actual value in your PHP code.)

[[DB_NAME_PREFIX]]

The prefix used for database tables.

[[FOCUSED_LANGUAGE_ID]]

Some panels, such as some Content and Menu Panels, have logic that refers to the language that the Admin is currently working in.

However the language that the Admin is currently working in may sometimes be tricky to find; it could be set in a refiner that is several branches up in the chain, it could be set in a refiner that was placed in a parent window, or it could be the language id of a parent window.

The CMS attempts to make finding this slightly easier for you by providing the [[FOCUSED_LANGUAGE_ID]]constant, which it will set to the current working language.

The current working language can be changed:

  • By creating a panel with a key named languageId
  • By creating a refiner named language

Otherwise it will be set to the default language, or 'en' if no language has been enabled yet.

(As with the other constants here, this will be escaped with quotes placed around it. You can use theFOCUSED_LANGUAGE_ID__NO_QUOTES constant instead if you need to access the actual value in your PHP code.)

[[MODULE_CLASS_NAME_PREFIX]]

Any Module that creates its own tables in the CMS will use an additional prefix for those tables.

For example, the user_comments table in the Comments Module can be accessed using [[DB_NAME_PREFIX]][[TRIBIQ_COMMENTS_PREFIX]]user_comments.

If you're trying to access another Module's prefix, be aware that this will only be defined after the Module has been included using the inc() command.

[[REFINER_ID]]

The value of the current refiner, if one is set.

[[REFINER__NAME]]

The value of the refiner NAME, where NAME is a refiner that has been used on either the current panel or a previous panel.

[[SQL_IN]]

When Organizer applies pagination, it runs two SQL queries.

The first query is used to sort the results, and generates a list of ids that are within the current pagination range.

The second query is used to fetch the column values for each row in the pagination range, and only runs on the ids found by the first query.

If you wish to access the list of ids found by the first query, you may use the [[SQL_IN]] constant.

As this constant is only defined in the second query, you can only use this in the SQL for columns, and only for columns that are not searchable or sortable.

[[ORGANIZER_MODE]]

The mode that Organizer is currently running in; you can see a list of modes here.

Using Multiple Comma-separated Values in an IN() statement

The [[COMBINE_ITEM]], [[REFINER_ID]] and [[REFINER__NAME]] constants are limited to only holding one value. If there are multiple values, only the first will be displayed.

If you wish to work on multiple values, you may instead use the[[COMBINE_ITEMS]] or [[REFINER_IDS]] constants which are designed to work as an IN() statement. For example:

WHERE alias.column_name IN [[COMBINE_ITEMS]]

You can also use constants of the format [[REFINER__NAME__S]] to access multiple values for a refiner used on either the current panel or a previous panel.

Attempting to Access an Undefined Constant

If you attempt to access a constant that hasn't been defined, then that constant will be replaced with a NULL.

Using other Constants

You can include any defined constant using this syntax, though you should be careful as some constants are not be designed for use in SQL and will not have been escaped.