-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create 05-14-2023 How to use SXA Content Tokens in a JSS solution
- Loading branch information
Showing
1 changed file
with
75 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
05-14-2023 How to use SXA Content Tokens in a JSS solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
How to use SXA Content Tokens in a JSS solution | ||
44 | ||
{ | ||
45 | ||
<span style="color: #008800; font-weight: bold;">public</span> <span style="color: #0066bb; font-weight: bold;">GetTokenizedTextFieldSerializer</span>(IFieldRenderer fieldRenderer):<span style="color: #008800; font-weight: bold;">base</span>(fieldRenderer) | ||
46 | ||
{ | ||
47 | ||
} | ||
48 | ||
| ||
49 | ||
<span style="color: #008800; font-weight: bold;">protected</span> <span style="color: #008800; font-weight: bold;">override</span> <span style="color: #008800; font-weight: bold;">void</span> <span style="color: #0066bb; font-weight: bold;">SetResult</span>(GetFieldSerializerPipelineArgs args) | ||
50 | ||
{ | ||
51 | ||
args.Result = <span style="color: #008800; font-weight: bold;">new</span> TokenizedTextFieldSerializer(<span style="color: #008800; font-weight: bold;">this</span>.FieldRenderer); | ||
52 | ||
} | ||
53 | ||
} | ||
54 | ||
</pre></div> | ||
55 | ||
<br /></div><div>Now you should add the GetTokenizedTextFieldSerializer processor to the getFieldSerializer, and patch it before GetDefaultFieldSerializer processor. Do not forget to specify the field types that this field serializer should be applied to, in our case single-line text and multi-line text field types.</div><div><br /></div><div><!--HTML generated using hilite.me--><div style="background: rgb(255, 255, 255); border-color: gray; border-image: initial; border-style: solid; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;"><pre style="line-height: 125%; margin: 0px;"><configuration xmlns:patch=<span style="background-color: #fff0f0;">"http://www.sitecore.net/xmlconfig/"</span>> | ||
56 | ||
<sitecore> | ||
57 | ||
<pipelines> | ||
58 | ||
<<span style="color: #008800; font-weight: bold;">group</span> groupName=<span style="background-color: #fff0f0;">"layoutService"</span>> | ||
59 | ||
<pipelines> | ||
60 | ||
<getFieldSerializer> | ||
61 | ||
<processor patch:before=<span style="background-color: #fff0f0;">"*[@type='Sitecore.LayoutService.Serialization.Pipelines.GetFieldSerializer.GetDefaultFieldSerializer, Sitecore.LayoutService']"</span> type=<span style="background-color: #fff0f0;">"Your.Namespace.GetTokenizedTextFieldSerializer, your.dllName"</span> resolve=<span style="background-color: #fff0f0;">"true"</span>> | ||
62 | ||
<FieldTypes hint=<span style="background-color: #fff0f0;">"list"</span>> | ||
63 | ||
<fieldType id=<span style="background-color: #fff0f0;">"1"</span>>single-line text</fieldType> | ||
64 | ||
<fieldType id=<span style="background-color: #fff0f0;">"3"</span>>multi-line text</fieldType> | ||
65 | ||
</FieldTypes> | ||
66 | ||
</processor> | ||
67 | ||
</getFieldSerializer> | ||
68 | ||
</pipelines> | ||
69 | ||
</<span style="color: #008800; font-weight: bold;">group</span>> | ||
70 | ||
</pipelines> | ||
71 | ||
</sitecore> | ||
72 | ||
</configuration> | ||
73 | ||
</pre></div> | ||
74 | ||
<br /></div><div>And that's it guys, this should fix the problem and now you can create how many content tokens you want and re-use them throughout the whole site.<br /><br />Please take your conclusions and leave a comment!</div><div><b><br /></b></div><div><b>References</b></div><div><b><br /></b></div><div><div>https://sitecore.stackexchange.com/questions/29893/sxa-content-tokens-in-layout-service</div><div><br /></div><div>https://doc.sitecore.com/xp/en/developers/hd/211/sitecore-headless-development/customize-the-serialization-of-a-sitecore-field.html</div></div><div><br /></div><div>https://www.getfishtank.com/blog/embracing-power-content-tokens-sitecore-sxa</div><div><br /></div><div>https://doc.sitecore.com/xp/en/users/sxa/103/sitecore-experience-accelerator/create-and-insert-a-content-token.html</div><div><br /></div><div>https://doc.sitecore.com/xp/en/developers/sxa/103/sitecore-experience-accelerator/content-tokens.html</div> | ||
75 | ||
</div> | ||
Configurações de postagens | ||
Marcadores | ||
SXA Content Token,Sitecore Pipelines,Sitecore,JSS,SXA, | ||
Nenhuma sugestão relevante | ||
Publicada em | ||
14/05/2023 11:17 | ||
Links | ||
Local | ||
Descrição da pesquisa | ||
Opções |