Jayakumar
Occasional Observer

Fetch record from database and display in DOM

Jump to solution

Hello,

In format template, can we fetch data from data source?

 

0 Kudos
1 Solution

Accepted Solutions

Hallo Jayakumar,

I'm sorry, but I can't find an out-of-the-box solution for this requirement.
The following should work:
Write a VALUE service that is used in the rules to transfer the corresponding content from the selected dataset into a text field of the link.
Define the text field into which the content is copied as link text on the properties tab of the link template. (The content of a corresponding text field is the one that is displayed in the DOM).

The problem that, in my estimation, cannot be solved at the moment without a VALUE service is to take the text field from the record. It is possible, for example, if a CMS_INPUT_COMBOBOX is used to select the data set, to use its ID per rule without any problems:
<RULE>
<WITH>
<PROPERTY name="ENTRY" source="COMBOBOX"/>
</WITH>
<DO>
<PROPERTY name="VALUE" source="TEXTFIELD"/>
</DO>
</RULE>
But then the ID would be shown within the CMS_INPUT_DOM, which doesn't help editors.

You can make two different feature requests if you want an out-of-the-box solution (but this will take some time):
Either the already existing VALUE service should be extended accordingly, so that it can take over data from a data set by means of another input component (at the moment this is only possible via the GID, but you can't get it by rule from an input component with a data set).
Or it should be possible to select a corresponding input component (e.g. CMS_INPUT_COMBOBOX or FS_DATASET) as text field for the link.

 

Best regards
Holger

View solution in original post

0 Kudos
5 Replies
hoebbel
Crownpeak employee

Dear Jayakumar

you can define a CMS_HEADER within a format template and within this CMS_HEADER you can define a contentSelect function to fetch entities. (Just write the tags at the beginning of the source code of the formattemplate:
<CMS_HEADER>
<CMS_FUNCTION name="contentSelect" resultname="fr_myfunction">
...
</CMS_FUNCTION>
</CMS_HEADER>
...$CMS_FOR(for_entity,fr_myfunction)$...$CMS_END_FOR$...

I hope you can solve your problem with this information.

Hint: The result of the contentSelect function is only valid within the format template. So you should create the output within the format template itself. 

Best regards
Holger

0 Kudos
Jayakumar
Occasional Observer

Is there any possible options to enable editors to select the requires dataset to be included in the DOM? The dataset contains a simple text.

Is it possible to bring the functionality of FS_INDEX in DOM?

0 Kudos

@Jayakumar wrote:

Is there any possible options to enable editors to select the requires dataset to be included in the DOM? The dataset contains a simple text.

Is it possible to bring the functionality of FS_INDEX in DOM?


If you use a link instead of a format template, you can use almost all input components (they must be language independent [useLanguages="no"]). 

You cannot use the CMS_HEADER tag within the output channel of a link template, but if you need a contentSelect function there, you can use a format template via $CMS_RENDER (template:<uid>)$ and define the contentSelect function there.

Another solution (for more technical editors) could be to define a format template, in which the marked text is used as value of a CMS_VALUE_PARAM of the contentSelect function. Should work like this:

<CMS_FUNCTION name="contentSelect" resultname="...">
	<CMS_PARAM name="schema" value="..." />
	<CMS_VALUE_PARAM name="myParam" value="#content" />
	<QUERY entityType="...">
		<FILTERPARAM parameter="myParam" datatype="java.lang.String" value="%"/>
		<LIKE attribute="..." parameter="myParam"/>
	</QUERY>
</CMS_FUNCTION>

But this is a very technical solution and won't work with normal editors! 

0 Kudos
Jayakumar
Occasional Observer

Hello,

Please verify the step by step screen shot added for your reference.

Screen 1:

Jayakumar_0-1643093685879.png

 

 

Screen 2:

I am selecting link template,

 

Jayakumar_1-1643093685887.png

 

 

 

 

 

Screen 3:

Populating database values,

Jayakumar_2-1643093685894.png

 

 

Screen 4;

After Text Snippet #192 is selected ,

 

Jayakumar_3-1643093685898.png

 

 

 

The value inside #192,

Ex: “Text of snippet should show up in actual text”

Should populate in the Content

Jayakumar_4-1643093685903.png

i want to bring the selected values in the content.

please do the needful.

 

0 Kudos

Hallo Jayakumar,

I'm sorry, but I can't find an out-of-the-box solution for this requirement.
The following should work:
Write a VALUE service that is used in the rules to transfer the corresponding content from the selected dataset into a text field of the link.
Define the text field into which the content is copied as link text on the properties tab of the link template. (The content of a corresponding text field is the one that is displayed in the DOM).

The problem that, in my estimation, cannot be solved at the moment without a VALUE service is to take the text field from the record. It is possible, for example, if a CMS_INPUT_COMBOBOX is used to select the data set, to use its ID per rule without any problems:
<RULE>
<WITH>
<PROPERTY name="ENTRY" source="COMBOBOX"/>
</WITH>
<DO>
<PROPERTY name="VALUE" source="TEXTFIELD"/>
</DO>
</RULE>
But then the ID would be shown within the CMS_INPUT_DOM, which doesn't help editors.

You can make two different feature requests if you want an out-of-the-box solution (but this will take some time):
Either the already existing VALUE service should be extended accordingly, so that it can take over data from a data set by means of another input component (at the moment this is only possible via the GID, but you can't get it by rule from an input component with a data set).
Or it should be possible to select a corresponding input component (e.g. CMS_INPUT_COMBOBOX or FS_DATASET) as text field for the link.

 

Best regards
Holger

0 Kudos