ASPX templates
Version 4.x > ASPX templates > GetDocumentURL is not correct using QueryRepeater and custom query View modes: 
User avatar
Member
Member
mrogers-brainloaf - 5/3/2009 4:34:40 PM
   
GetDocumentURL is not correct using QueryRepeater and custom query
I have a query I wrote to return News items that are part of a category named "News" (i have made other categories).

I use a query repeater
<uc1:repeater runat="server" ID="NewsRepeater" ClassNames="CMS.News" 
QueryName="CMS.News.RandomList" TransformationName="CMS.News.NewsTabs" SelectedItemTransformationName="CMS.News.NewsTabs"
ResultsPosition="top" Path="/%" />

RandomList is my query and works. It returns CMS.New classes. But in the transformation:
<a href="<%# GetDocumentUrl() %>">
<%# Eval("NewsTitle") %></a>
<p><%# Eval("NewsSummary") %></p>

GetDocumentURL returns default.aspx instead of the URL of the news item. If I use CMSRepeater the transformation works properly, but I cannot use my custom query. So either I need to know how to get GetDocumentURL to work in the QueryRepeater or I need a way to select News Items with category "News" using CMSRepeater.

Thanks

User avatar
Member
Member
zhaojicheng-artmtech - 5/4/2009 7:14:20 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
post your "CMS.News.RandomList" content

User avatar
Member
Member
mrogers-brainloaf - 5/4/2009 8:48:58 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
It doesn't work regardless of the query used.
SELECT ##TOPN## ##COLUMNS## FROM CONTENT_news WHERE ##WHERE## ORDER BY newid()

User avatar
Member
Member
zhaojicheng-artmtech - 5/4/2009 11:34:53 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
the "CONTENT_news " does not contain the document url.
you should used the "View_CONTENT_news_Joined"

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 5/12/2009 8:33:48 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
Hi,

Could you please try to use the View_Tree_Joined to get all necessary data from DB to resolve the URL?

Best Regards,
Juraj Ondrus

User avatar
Member
Member
chris.percival-oakwood-dc - 4/8/2010 3:41:31 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
I have the same problem. I am using the QueryDataList webpart with a custom query to join a document type table to a custom table. What exactly do I need to return in order for GetDocumentURL (or any other transformation method) to work?

User avatar
Member
Member
chris.percival-oakwood-dc - 4/8/2010 8:51:05 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
I fix it in the end by creating a new view in the database and joined my document type table to View_CMS_Tree_Joined on DocumentForeignKeyValue = ItemID. My custome query then queries against this view and the correct fields seem to be returned for GetDocumentURL to function.

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 4/9/2010 2:42:32 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
Hello,

please note there is special view containing document and document type data created automatically for every document type so you can use this view instead of joining your document type table with View_CMS_Tree_Joined view (as it will be more efficient). The name of view depends on name of doc. type, e.g. view for news is named: "View_CONTENT_news_Joined"

Best Regards,
Martin Dobsicek

User avatar
Member
Member
chris.percival-oakwood-dc - 4/9/2010 2:50:39 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
Oh yes, so there is! This would be good information for the documentation (unless its there already). I gave up entirely with this method in the end because I discovered that QueryDataList doesn't have a SelectedItemTransformationName property like CMSDataList does.. :(

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 4/9/2010 6:41:36 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
Hello,

You could optionally ensure selected item transformation manually as described in How to ensure selected item transformation in query repeater article. The procedure for QueryDataList is the same.

Best Regards,
Martin Dobsicek

User avatar
Certified Developer 12
Certified Developer 12
chetan2309-gmail - 8/7/2013 8:13:58 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
I am facing exactly same problem. Any direct solutions for this without going to .NET code changes?

Many Thanks
Chetan

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 8/7/2013 8:19:44 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
Hello,

What version of Kentico do you use? This is very old thread of already abandoned version. Moreover, the solution to that issue is in the thread - you have to use the View or join appropriate tables in your custom query to get all the data you want to use.

Next time, please submit your post into appropriate version group. Thank you.

Best regards,
Juraj Ondrus

User avatar
Certified Developer 12
Certified Developer 12
chetan2309-gmail - 8/7/2013 8:26:19 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
Hi Juraj,

I thought of not creating a new thread for same problem. Apologies.

I am not able to figure out the discussion.

Do I need to return DocumentUrl via my query?

How can I modify my query considering this to be my query.

select
x1.Specie
, x1.Headline,
x1.Author,
x1.Image,
x1.View_CONTENT_pm_article_Joined
from pm_article x1
where
(
select count(*)
from pm_article x2
where x2.Specie = x1.Specie
and x2.Headline <= x1.Headline
) <= 2
order by Specie, Headline, Author;

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 8/7/2013 8:38:53 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
Hi,

Yes, you need to return the data you want to use in the transformation. Otherwise, how the repeater would know that you want to use this or that?
So, you need to either join more tables in your custom query and return all the columns you want to work with in a transformation or, you can also use the View_CMS_Tree_Joined where the most used colums are joined and available for use.

Best regards,
Juraj Ondrus

User avatar
Certified Developer 12
Certified Developer 12
chetan2309-gmail - 8/7/2013 8:51:07 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
That's understandable that I need to get the column. However the point do I need to manually store the url while creating the doc in the field?

This would be very bad for us, since the data will be filled by end users via form.

Do you have any examples of View_CMS_Tree_Joined? I am very new to Kentico environment so I am very clueless about trying to figure out about what you said

Thanks

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 8/8/2013 12:33:36 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
Hello,

I am not sure what example you are looking for. It is a view in the DB so you can take a look into the DB to see what columns are in that view.

Also, you should check the transformation functions and what data they need. For example, the GetDocumentURL function needs these data to compose the URL:

SiteName, NodeAliasPath and DocumentUrlPath

Otherwise, you have to compose the URL on your own within the transformation using the data you are returning by your query.

Best regards,
Juraj Ondrus

User avatar
Certified Developer 12
Certified Developer 12
chetan2309-gmail - 8/8/2013 11:23:29 AM
   
RE:GetDocumentURL is not correct using QueryRepeater and custom query
Thanks for your help Juraj. I was able to write query and perform inner join over my table and this table.

Appreciate for the direction provided

Regards,
Chetan