How to get the name of the news Article in GoogleNewsSitemap using kentico CMS

I am using Kentico 5.5R2 for my site where I want to generate GoogleNewsSitemap. So far, my code is able to retrieve the url and publication date of newarticle, but I can’t get the title of the news article dynamically here the code

<url> <loc><%# GetAbsoluteUrl(GetDocumentUrl()) %></loc> <news:news> <news:publication> <news:name>Yourwellness </news:name> <news:language>eng</news:language> </news:publication> <news:genres>PressRelease, Blog</news:genres> <news:publication_date> <%# GetDateTime("DocumentModifiedWhen", "dd-MMM-yy")%> </news:publication_date> <news:title>method for fetching title Comes here </news:title> <news:keywords>Health</news:keywords> </news:news> </url> 

I tried many methods to get the header, but it looks empty.

+4
source share
4 answers

<% # Eval ("DocumentName")%> is the default value for node if you are not using something else with a custom document type

+1
source

Have you tried just plain Eval? I don’t remember the name of the field, not on my working computer, but probably one of them:

 <%#Eval("DocumentTitle") %> <%#Eval("Title") %> 
0
source

You can search for:

 <%# Eval("DocumentName") %> 

It depends on what type of document is used for the title. This could be the name of the document, as described above, or something like "NewTitle".

0
source

Where do you use this code and which web part do you use? Have you tried to get the header in the code?

0
source

Source: https://habr.com/ru/post/1383002/


All Articles