YAFLogo

notbob
  • notbob
  • 50.6% (Neutral)
  • YAF Forumling Topic Starter
16 years ago
hi all,

I'm integrating YAF into our software and it's been an interesting ride so far, as we've run into several issues over versions with the AjaxToolkit but I got those solved.

Now I'm onto what seems like an obvious and easy thing to do but has turned out to be a major headache.

I want to place the ForumActiveDiscussion control on a page not inside of YAF, it's actually in the folder right above forums.

Problem is when you go to run it the PageContext is always null and the localization routines toss a ton of errors up.

Can someone explain to me how to utilize this control outside of YAF's main forum control?

Our end goal is to have the active discussions show up on a users homepage elsewhere in the system, if I could just get some basic tips to get past this pagecontext problem I should be good to go.

Also is there a way to join the contributors group for this project? I'm a full-time .net developer and would love to help out.

Thanks

Bob

Sponsor
muneeb_baig
16 years ago

Our end goal is to have the active discussions show up on a users homepage elsewhere in the system, if I could just get some basic tips to get past this pagecontext problem I should be good to go.

I am not an expert but can help you achieving your task.

In your ASPX file add the following:


<asp:DataList ID="dlstTopicsInDiscussion" runat="server" CellPadding="0" ForeColor="Black"
 ShowFooter="False" ShowHeader="False" Width="99%" BorderColor="#83CCC3" BorderStyle="None">
    <ItemTemplate>
    <table width="100%" cellpadding="0" cellspacing="0">
    <tr>
       <td class="RightMenuOutlineBKG" style="width: 1px; height: 21px;"></td>
       <td style="width: 96%; height: 21px; text-align: left;">
        <asp:HyperLink ID="hlTopicsInDiscussion" runat="server" 
         Font-Bold="false" Font-Underline="false" ForeColor="Black" 
         Text='<%#("&nbsp;") +  Eval("Topic") %>'
         ToolTip='<%# "Last post by: " + Eval("LastUserName")+"\r\n on: " + Eval("LastPosted") + "\r\n posted to: " + Eval("Forum") %>'
         NavigateUrl='<%#(System.Configuration.ConfigurationManager.AppSettings["ForumPageInternal"]) + ("?g=posts&t=") + Eval("TopicID") %>'
         Width="98%"></asp:HyperLink>
       </td>
    </tr>
   </table>
   </ItemTemplate>
</asp:DataList>

In code behind add the following and call it from Page Load:


	private void PopulateTopicsInDiscussion()
	{

		DataTable dt = ((DataTable)(Cache["TopicsInDiscussion"]));
		if (dt == null)
		{
			try
			{
			
				dlstTopicsInDiscussion.DataSource = null;
				dt = yaf.DB.topic_latest(1, 5, 1);
				if (dt.Rows.Count < 1)
				{
					//try again
					return;
				}
				DateTime dtExpiry = DateTime.Now.AddHours(m_nCacheExpirationTime);
				Cache.Insert("TopicsInDiscussion", dt, null,
					dtExpiry, System.Web.Caching.Cache.NoSlidingExpiration);

			}
			catch
			{
				//do whatever you want...
				return;
			}
		}
		dlstTopicsInDiscussion.DataSource = dt;
		dlstTopicsInDiscussion.DataBind();
	}

Hope this will solve your problem.

Happy Coding...


-muneeb

test2005
16 years ago
Why not use the RSS function?


.....the man in black fled across the desert..........and the gunslinger followed.....