Deivi Robles
Deivi Robles

Reputation: 18

How can set in page title with the document name in Kentico?

I need set the page title dynamically because in my node actually exist 1000 documents, so I think that exist a way to do it automatly. I'm using Kentico 10

Upvotes: 0

Views: 387

Answers (2)

Dragoljub Ilic
Dragoljub Ilic

Reputation: 247

I'm not sure that I understand your question, but if you want:

  1. To set page title for your documents, to be shown in browser, you should follow link in documentation.

  2. To iterate over all nodes and update document name/ page title with some custom text, you should look into Kentico API docs. You should look into section for Updating published pages (see code example bellow):

    TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); var pages = tree.SelectNodes() .Path("/Articles/", PathTypeEnum.Children) .WhereLike("DocumentName", "Coffee%") .OnSite("DancingGoat") .Culture("en-us"); foreach (TreeNode page in pages) { page.DocumentName = "Updated article name"; page.SetValue("ArticleTitle", "Updated article title"); page.Update(); }

Upvotes: 0

Brenden Kehren
Brenden Kehren

Reputation: 6117

Use a macro. In the parent page of all your documents, you can use a field from the specific page type or use the document name.

For example if you have a page tree like this:

-Products
--Product 1
--Product 2

In the -Product pages metadata add

Page title: {%DocumentName%}
or
Page title: {%PageTypeField%}

Using the macro will allow you to dynamically get those values vs. having to code each one manually.

Upvotes: 2

Related Questions