Querying Field Values

Files can also be included in automatically generated tables of contents or formatted there, dependant on field values. The following code checks whether the custom field ShowInTocList has a value.

<npsobj name="ShowInTocList" condition="isNotEmpty">
  ...
</npsobj>

With condition="isEmpty" you check whether a field value is empty. However if you wish to compare the value of a field such as title with a string, for example, use code in accordance with the following example:

<npsobj name1="title" value2="A File Title" condition="isEqual">
  ...
</npsobj>

If the field value is exactly equivalent to the entered string, the CMS processes the code before </npsobj>. Conversely, you can use condition="isNotEqual" to test for non-equivalence.

You can test whether the value of a field begins or ends with a particular string with hasPrefix or hasSuffix. The following example checks whether the title of the file begins with the string Datasheet:

<npsobj name1="title" value2="Datasheet" condition="hasPrefix">
  ...
</npsobj>

Query date fields

If you query date fields in conditional NPSOBJ instructions, then you should consider that the CMS applies the comparison to the canonic form of the date. In this format a date is represented as a 14-place string, beginning from the left with the year, month, day, hour and seconds, whereby except for the four-place year all entries are two-place. For example the date Dec. 18, 2010 is saved as 20101218000000.

Use hasPrefix as a comparison operator to compare only the relevant characters of the saved date with a string. Please note that the parameters in the comparison operations hasPrefix and hasSuffix are not commutative: the respective index with which name and value are provided determines the position of the parameter. The index is mandatory.

In the following example the files are determined that were last changed on May 15, 2011:

<npsobj condition="hasPrefix" name1="lastChanged" value2="20110515"> ...
</npsobj>

All files that were last changed in May 2011 can be found with the following code.

<npsobj condition="hasPrefix" name1="lastChanged" value2="201105"> ...
</npsobj>

Please note that every date value in the CMS is related to the timezone GMT. Thus if you wish to check whether a file is valid based on its validity period, you must use the value of the time comparison translated into GMT as value2.