YAFLogo

Posted by: jimbo2 - Friday, 13 January 2012 16:00:25
Hi, I am currently building a community in ASP.NET with the YAF.NET board. I want to write a control that displays the last 5 threads of the forum. I managed the get the latest 5 threads via SQL. [quote] SELECT TOP (5) TopicID, ForumID, UserID, UserName, Posted, Topic, Views, Priority, PollID, TopicMovedID, LastPosted, LastMessageID, LastUserID, LastUserName, NumPosts, Flags, IsDeleted, IsQuestion, AnswerMessageId, LastMessageFlags, TopicImage FROM yaf_Topic ORDER BY Posted DESC [/quote] What is the easiest way to build the URL of the thread to create a hyperlink on my website? Are there any public yaf.net-methods that I can use? Thanks in advance jimbo

Posted by: tha_watcha - Friday, 13 January 2012 19:56:45
Use YafBuildLink for that... [code=csharp]YafBuildLink.GetLink(ForumPages.posts, "t={0}", topicID)[/code]

Posted by: jimbo2 - Friday, 13 January 2012 21:07:02
Hey, thanks for the quick reply. I have faced some problems with your solution: 1. GetLink returns a "&" instead of a "&" in the url which makes the url invalid. 2. GetLink does not seems to respect the app.config. The method returns: http://localhost:54248/forum/default.aspx?g=posts&t=3 instead of http://localhost:54248/forum/forum.aspx?g=posts&t=3 3. The rewrite rules are not applied. I can solve the first problems on my own by simply using string.replace() but how to solve the url rewriting problem? thanks in advance jimbo

Posted by: jimbo2 - Friday, 13 January 2012 22:37:34
Regarding the url rewriting stuff: I found a method called BuildUrl in YAF.Core.RewriteUrlBuilder. I tried to use this method like this without success: [quote] YAF.Core.RewriteUrlBuilder rewriteBuilder = new YAF.Core.RewriteUrlBuilder(); return rewriteBuilder.BuildUrl(YAF.Utils.YafBuildLink.GetLink(YAF.Types.Constants.ForumPages.posts, "t={0}", topicID)); [/quote]