Get Meta Title combined with Kentico settings for page via API in a MVC website

Peter van Dijk asked on July 5, 2021 11:31

How do I get the page title combined with the page title content settings in a MVC website? The page settings are set to the following: {%pagetitle_orelse_name%} | {%prefix%}. When I run

resolver.ResolveMacros("{%pagetitle_orelse_name%} | {%prefix%}")

it returns "|".

resolver SetNamedSourceData is set to the current treeNode

resolver.SetNamedSourceData("CurrentDocument", treeNode).

The same happens with MacroResolver.Resolve("{%pagetitle_orelse_name%} | {%prefix%}"); // output "|"

Correct Answer

Juraj Ondrus answered on July 8, 2021 10:05

Ohhh sorry for the confusion. The setting was meant for portal engine sites. So, in the MVC app, you need to get the values of the document meta data fields as you are getting values for any other fields and format them as you need. That setting is not available. Or, you would need to use the settings API to get its value, process it and then set the meta data accordingly using custom code.
Or, upgrade to Kentico 13 where were made changes in this regards and the setting is taken into account when using the API I mentioned in my first post.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Juraj Ondrus answered on July 7, 2021 14:26

I would recommend using the API described in the documentation and it should also respect the page title format settings.

0 votesVote for this answer Mark as a Correct answer

Peter van Dijk answered on July 8, 2021 09:06

The documentation you're referring to is for Kentico 13 and the problem occurs in Kentico 12. There is no extension method @Html.Kentico.PageTitle() in Kentico 12.

0 votesVote for this answer Mark as a Correct answer

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