Bind field to Metadata title.

Targutai Yesugei asked on August 25, 2017 12:17

Hello.

I want to setup my page type so when you input some text into custom field, metadata title will get this value too. I know, that i can use "{%FieldName%}" macro in Metadata title, but it requires to be added whenever i want to create new page, and i want this to be available by default.

Thanks in advance.

Correct Answer

Brenden Kehren answered on August 25, 2017 14:32

In your master page's page title, enter the macro:

{% if(CurrentDocument.ClassName == "your.classname"){DocumentName + " - " + CustomFieldName}else{DocumentName} |(identity)GlobalAdministrator%}

This macro will recuse through the rest of the content tree. So this is assuming you have NOT added the CustomFieldName to every page type you use in your site. It checks to see if it is the class name you want and adds the field value to the document name. This is a "set one time and leave it" functionality.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Trevor Fayas answered on August 25, 2017 14:11

couple options. first meta titles are by default inherited from parent, so if you set the meta title macro on a parent children will inherit, for some sites I actually have a "use this field or site setting" macro in each meta field and have meta "fields" on the page type itself because it can be a pain to inherit and set for each page.

I also created (just never published on marketplace) a form control that sets the meta data that will do what you want, I can get it to you.

0 votesVote for this answer Mark as a Correct answer

Targutai Yesugei answered on August 25, 2017 16:29

Thanks a lot, i'll try you advices

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on August 28, 2017 14:27

The way you have expressed this problem I am assuming you would not like to define field name over and over.

  1. I would create "CustomMetaTitle" field for all my custom page types.
  2. I will go the Metadata tab and define in Meta title field box this field through a macro {%CustomMetaTitle%}
  3. I will leave the inheritance as it is as I am keeping my field name consistent and at every level the property will be fetched by accessing the field at that level through a macro. So in case I didn't fill the entry it will be empty.

This should do the trick.

Thanks, Chetan

0 votesVote for this answer Mark as a Correct answer

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