Technical support This forum is closed.
Version 1.x > Technical support > Title Value View modes: 
User avatar
Member
Member
BrianP - 4/17/2006 5:28:55 PM
   
Title Value
We are using this

<cc1:CMSRepeater ID="CMSRepeater1" runat="server" SelectNodesPath="/News/%" SelectNodesClassName="cms.news"
SelectNodesOrderBy="NewsReleaseDate desc" TransformationName="cms.news.blankpreview"
SelectedItemTransformationName="cms.news.default">
</cc1:CMSRepeater>

In using that is there a way to extract just the title of the news article for use someplace else?

User avatar
Member
Member
Martin_Kentico - 4/18/2006 12:59:44 PM
   
Re: Title Value
Hello Brian,

Thank you for your post

If you just need to get the documents data, you can use the method TreeProvider.SelectNodes(...) to get the DataSet containing the tree data you need. You can use it like this:

Dim ds as DataSet = Functions.GetTreeProvider.SelectNodes("/News/%", Kentico.CMS.TreeEngine.TreePathTypeEnum.AliasPath, "cms.news", Nothing, "NewsReleaseDate desc")


If I can be of any further help, please let me know

Best Regards

User avatar
Member
Member
BrianP - 4/18/2006 1:39:14 PM
   
Re: Title Value
Wont this bring the the value of the url essentially? Many times the title is truncated.

If the URL is http://melodytrip.com/News/Caramoor%20Jazz%20Festival%20Announc.aspx

would the value of ds be Caramoor Jazz Festival Announc

The title displays as Caramoor Jazz Festival Announces Dates, Performers

Thanks

User avatar
Guest
admin - 4/18/2006 1:58:14 PM
   
Re: Title Value
Hi Brian,

the DataSet will contain all the fields of the News document type, including the full NewsTitle that you can then display on the page.

You can also use Functions.GetTreeProvider.SelectSingleNode to retrieve some particular document of Functions.GetCurrentDocument to retrieve the current document.

Please let us know if you need any help with that.

Best Regards,

User avatar
Member
Member
Martin_Kentico - 4/18/2006 2:01:01 PM
   
Re: Title Value
Hi,

The Title you are talking about is not actually Title, but node AliasName, that is limited to about 30 characters. This Alias Name is created from the actual title item value, that you set and that is part of your document, for example for CMS.Article the title item is ArticleName.

The DataSet you get is not actual value, it is set of the tables, that contains the rows filled with the document data items.

If you need to get the URL, you should use the function Functions.GetUrl(aliasPath) with the aliasPath you get from the item column "AliasPath", when you need the title, use the title column name instead of the AliasPath column name.


The code example for your case would be:

Dim ds as DataSet = Functions.GetTreeProvider().SelectNodes("/News/%", Kentico.CMS.TreeEngine.TreePathTypeEnum.AliasPath, "cms.news")

Dim url as String = Functions.GetUrl(ds.Tables(0).Rows(0).Item("AliasPath"))

Dim title as String = ds.Tables(0).Rows(0).Item("NewsTitle")

Best Regards

User avatar
Member
Member
BrianP - 4/18/2006 9:10:04 PM
   
Re: Title Value
I think I am getting closer

At the top of my page I have

<script runat="server">

protected void Page_Load(object sender, System.EventArgs e)
{
DataSet ds = WebProject.Functions.GetTreeProvider().SelectNodes("/News/%", Kentico.CMS.TreeEngine.TreePathTypeEnum.AliasPath, "cms.news");
string title = ds.Tables[0].Rows[0]["NewsTitle"].ToString();
// Add the page title to the header element.
Page.Header.Title = title;

}

</script>

down a bit I have

<cc1:CMSRepeater ID="CMSRepeater1" runat="server" SelectNodesPath="/News/%" SelectNodesClassName="cms.news"
SelectNodesOrderBy="NewsReleaseDate desc" TransformationName="cms.news.blankpreview"
SelectedItemTransformationName="cms.news.default">
</cc1:CMSRepeater>


So for this http://melodytrip.com/News/Reggae%20Sunsplash%20Returns.aspx

Im getting a different title showing up than Id expect.

Thanks for all your help!

User avatar
Member
Member
Martin_Kentico - 4/19/2006 8:25:17 AM
   
Re: Title Value
Hi,

When you look closely to the nodes selection code, it will select all the nodes under the /News document, so the first table row (indexed by 0) corresponds to the first CMS.News document under /News. You need to edit the selection path to get the particular document you need or use another index to get the next documents under the same node or use the function Functions.GetCurrentDocument() instead to get current document data.

You will find detailed information about retrieving document data within Kentico CMS Developer's Guide, at the topic Using Kentico CMS API (Retrieving documents ...)

Best Regards

User avatar
Member
Member
BrianP - 4/19/2006 2:39:21 PM
   
Re: Title Value
Thanks -- Ideally I think I will have to end up editing the GetPageTitleTag( string defaultAliasPath ) function.

Right now it seems to be using the menuitempagetitle, for Search Engine Optimization it would be benefical to use the newstitle.

User avatar
Member
Member
Martin_Kentico - 4/19/2006 2:49:23 PM
   
Re: Title Value
Yes, that would be probably the best way to do in your case.

You can also remove the title information generation and use the code of your own. After all, the CorporateSite is just a simple example of what you can do.

Best Regards