Start page / Template development / Forms / Input components / INDEX / Access to FS_INDEX

Access to FS_INDEX data

Contents
Important Depending on the implementation of a DataAccessPlugin - the source of data which is referenced in FS_INDEX - authentication is required in order to poll and display data from a web service (see aspect DataAccessControlling on the page Data Access Plug-in (Plug-in Development). In this case, successful access to details of data in an FS_INDEX input component depends upon the specific implementation of the DataAccessPlugin.

Access via FormData objects

When an FS_INDEX input component is accessed via a FormData object, an Index type object is returned, which contains a Record object for each index entry. The Index object enables the index entries to be managed and new entries to be created (see Index data type).

FS_INDEX output example:
(in this case DatasetDataAccessPlugin)

...
$CMS_FOR(entry,st_index.values)$
$CMS_VALUE(entry.formData.tt_headline)$
$CMS_END_FOR$
...

A Record object only contains the String identifier of the referenced data object provided by the DataAccess plug-in. To access the actual data of an entry, a String identifier of the DataAccess plug-in associated with the index component must be resolved to a data object (see Record data type).

Important Rendering of an FS_INDEX input component using $CMS_VALUE(...)$ is no longer supported and will cause generation warnings (“use of deprecated value generation method for an index editor”). Please always use $CMS_FOR(...)$ for the rendering (see FS_INDEX output example).

Access via the API (example):

FormData fd = ...;
Index index = fd.get(language, "pt_index").get();
DataAccessSession dataAccessSession = index.createSession(context);
...
for (Index.Record record : index) {
String myIdentifier = record.getIdentifier();
Dataset ds = (Dataset) dataAccessSession.getData(myIdentifier);
...
}

Access in template set and snippet definitions

In template set and snippet definitions of templates, by contrast, when an FS_INDEX input component is accessed, an IndexAccessor type object is returned, which facilitates read access to the String identifiers of the entries saved in the component and to the data objects, which correspond to the entries and have been resolved via the DataAccess plug-in associated with the index component (see IndexAccessor data type).

Important Restriction: If you access an FS_INDEX input component via a FormData object inside a template set, an Index (not IndexAccessor) type object is returned. There is no direct access to the data of the FS_INDEX input component in this case either (see Access via FormData objects description and example above).

From Available from FirstSpirit Version 5.2R4, additional interfaces which are able to display these external data objects in the form of a snippet are available in this area. To this end, the method getSnippets (in Bean syntax: .snippets) has been introduced:

FS_INDEX_VAR.snippets

This method returns a list. You can get the desired element of this list by indicating the position number (in brackets, counting begins with 0).
Use the following syntax for being able to get the values of the snippets of the different entries of an FS_INDEX component:

FS_INDEX_VAR.snippets[0].thumbnail
FS_INDEX_VAR.snippets[0].header
FS_INDEX_VAR.snippets[0].extract

Here,

  • thumbnail returns the value of the field Thumbnail
  • header returns the value of the field Label
  • extract returns the value of the field Extract

of the snippet definition of the – in this case – first entry of the associated data access plugin.
See also interface DataSnippet (package de.espirit.firstspirit.agency).

The graphic shows the call in a page template on the “Snippet” tab for:

  • [1] an image (“Thumbnail” field)
  • [2] a title (“Label” field)
  • [3] a text excerpt (“Extract” field)

The preview [4] then displays the data from the external source in the snippet. This content is subsequently displayed in search dialogs [5] and reports in SiteArchitect and ContentCreator in the same way as conventional FirstSpirit objects.

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.5 | Data privacy