Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Retrieve Content Fragment tags and post on page properties while keeping synced with data layer

Avatar

Adobe Champion

Question regarding use and retrieval of tags from content fragments and onto the page properties. Currently, our tags are added on the page property level of each of our templates – this feeds into the data layer, meta properties etc.

 

Future state: Want to populate components using tags at the component level, in this case, the content fragment level. Is it possible to expose the content fragment tags into tag fields of the page properties of our page for authors without duplicating tags and in order to avoid authors re-tagging content fragments?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Tagging to the CF by authoring once. Adding the tags to the page from the tags associated with the CF is programmatically automated. Because OOTB there is no way to achieve it. So you need to implement some custom logics.

View solution in original post

7 Replies

Avatar

Community Advisor

Hi @gdWebct 

While avoiding the difficulty of duplicate and redundant author tagging, it is possible to expose content fragment tags into tag fields at the page properties level. The Adobe Experience Manager (AEM) ecosystem's strategic modifications and seamless integration can be used to achieve this.

Here's a high-level outline of the steps you can take to achieve this future state:

  • Modify Content Fragment Model (CF Model): To start, you must change the CF Model for the content fragments you are using. Add a new "Tags" type multi-valued field to the CF Model. The tags relevant to each content fragment will be kept in this new field.
  • Tagging Content Fragments: Next, you can use the newly introduced "Tags" field in the CF Model to tag your content pieces with the necessary tags. These tags are directly manageable by authors within the metadata of the content fragment.
  • Content Fragment Component: To add the "Tags" field, make a new content fragment component or change an existing one. This component will be used to include content fragments on pages.
  • Page Properties Modification: Customize the page properties dialog of your page templates. Add a new field of type "Tags" to the page properties dialog. This field will be used to expose the tags from the content fragments.
  • Page Component Modification: Modify the page component or components where authors will include content fragments. In the component's dialog or editor, add a field that allows authors to select a content fragment along with the option to include its associated tags.
  • Scripting and Mapping: Implement the necessary scripting and mapping logic that will fetch the tags from the selected content fragment and populate them into the "Tags" field in the page properties.
  • Displaying Tags: Update the page template to display the tags from the page properties on the front end. These tags will now be sourced from the selected content fragment and will be available to populate data layers, meta properties, and other relevant areas.

By following these steps, authors can choose a content fragment along with its associated tags at the component level, and this data will be used to populate the tags in the page properties. This approach ensures that tags are managed at the content fragment level and avoids duplication or the need for authors to manually re-tag content fragments on the page level.

Avatar

Adobe Champion

@AsifChowdhury let's not mark this as accepted, yet, if you don't mind...if tagging at the cf but then again tag on page properties how are we avoiding tagging twice?

Avatar

Correct answer by
Community Advisor

Tagging to the CF by authoring once. Adding the tags to the page from the tags associated with the CF is programmatically automated. Because OOTB there is no way to achieve it. So you need to implement some custom logics.

Avatar

Adobe Champion

This should be pretty simple for your developers to achieve for you.  If your AEM implementation is reasonably up to date, the list of tags displayed on your site are being fetched from the Page sling model (java class) that backs all of your pages. By default (if using WCM Core, but also in most custom implementations as well) this will be fetching the list of tags from the Page Properties, which is what you're seeing. Your developers can override this function to also review all components on the page being rendered, pull in the tags from those components, and then create a list of unique tags from the Page Properties + Components/Content Fragments.

 

tl:dr; just a little bit of custom coding required, but should be able to be achieved by just updating a single sling model.