This should do the trick:
CMSContext.CurrentTitle = "asdasd";
Question
I have a page in Kentico that displays data from a custom table. One of the custom table fields is page title, and I can't figure out how to display the page title field in the...
<title></title>
...tags
The closest thing I can get to it is displaying part of the uri as the title, so /promo/page-title will create a title of
<title>page-title</title>
Wich is less than desirable for three reasons:
(EDIT)
Ok thanks to Raymond, and a bit of fumbling around, this is what I found works (posted in a custom table transformation):
<script runat="server">
private string Title { get; set;}
private string Description { get; set;}
private string Keywords { get; set;}
protected override void OnDataBinding(EventArgs e)
{
base.OnDataBinding(e);
// Get values from custom table
Title = DataBinder.Eval(this.DataItem, "seo_title").ToString();
Description = DataBinder.Eval(this.DataItem, "seo_desc").ToString();
Keywords = DataBinder.Eval(this.DataItem, "seo_keywords").ToString();
// Set values in meta tags
CMSContext.CurrentTitle = Title;
CMSContext.CurrentDescription = Description;
CMSContext.CurrentKeyWords = Keywords;
}
</script>
Solution 2
This should do the trick:
CMSContext.CurrentTitle = "asdasd";
OTHER TIPS
You can also create a custom macro in which you will use the API to get the custom table data. Then, use this macro in the page title/metadata settings