YAFLogo

jimbo2
  • jimbo2
  • 60.2% (Friendly)
  • YAF Camper Topic Starter
11 years ago
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



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
Sponsor

tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 3.0.3
11 years ago
Use YafBuildLink for that...

YafBuildLink.GetLink(ForumPages.posts, "t={0}", topicID)
jimbo2
  • jimbo2
  • 60.2% (Friendly)
  • YAF Camper Topic Starter
11 years ago
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
jimbo2
  • jimbo2
  • 60.2% (Friendly)
  • YAF Camper Topic Starter
11 years ago
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));

YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button