Assign a tag to a Page Template so when added to the content tree, the tag would already be applied?

Amy Patterson asked on March 17, 2022 19:04

We are adding page (menu item) templates that Inherit headers from the Parent pages. Any way to set a tag in the page template or layout before the template is added as a child but still inherit?

When I try and edit the template to find the tag setting in the edit page template, I do not see the option to set the tag, I only see the option to set a tag from the metadata tab from the content tree.

Is it possible to set a tag on a template page upfront, so when added it would be set by default?

Image Text

Recent Answers


Brian McKeiver answered on March 20, 2022 17:44

So not really out of the box. Tags are fields of the content itself and related to Pages (Documents). The data is stored in the DocumentTags field of a Page. Page templates and/or layouts are presentation layer (display only).

Now if you really wanted to, you could create a custom event handler and around the time of page creation try to enforce a tag being assigned to a page, but I wouldn't really recommend that. Another option would be to create your own custom form control that could return a default tag value based on the location or context of the new page, but that would be some work as well.

0 votesVote for this answer Mark as a Correct answer

Sophia Towne answered on March 23, 2022 08:00 (last edited on March 24, 2022 13:08)

The tag is used as a container to hold some HTML content hidden from the user when the page loads. The content inside

0 votesVote for this answer Mark as a Correct answer

Amy Patterson answered on March 24, 2022 14:40

Thank you Brain and Sophia. A custom event handler would mean opening the solution and adding more to the page event handlers, which could be a little dicey in an established Kentico 12 Portal site because all of the page menu types would contain that custom event handler, but it was a great suggestion for a customization for anyone that is building a new site and wants to add on to a page types events.

I figured out a little trick that will keep the page menu types the same, and automatically contain a tag when added to the content tree, and that is............ stay tuned for the next episode of the mysterious ways of Kentico Portal. :)

Ok, welcome back, here are the steps:

  1. ✽ Click on your Kentico flower and open the page types application.
  2. In the display name search for Page (menu item) and you should see Page (menu item) in the list ▤.
  3. ✌ Clone it.
  4. Give it a name so you know the automatic tagging would be applied if that page type is selected.
  5. ✐ Click the pencil to edit your new page menu item type.
  6. Click on the Fields tab.
  7. Add a new field, I named mine DocumentTags.

Now here is the automatic tag applying magic ۜ✌(◕‿-)✌

General

In the Default value box add your tag name that you want to automatically tag when that page type is added to the content tree. I called mine city.

Field Appearance

  1. In the Field caption text box, type Tags
  2. In the Form Control drop down, select Tag selector
  3. Click Save.

Now go to ✽ Pages application and right click on your content tree and select New... Add your sparkly -`🔳´- new page type. Name it, select a template, and save it to the content tree ┆. When the page loads and appears, open it, click on the form tag and locate your DocumentTag field and you should see your automatic tag show up.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.