Cloning the Forums Feature

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
9/14/2011 11:04:22 AM
Gravatar
Total Posts 42

Cloning the Forums Feature

Hi All,

Please I tried cloning the mojoPortal forums, and followed the steps in the documentation.

Cloning the blog feature was successful, and worked.

But for the forum, it was also successful, the script ran, and DB tables were created.

But when I add it to a page, nothing shows.

Please has anybody had this challenge before. What could be wrong?

9/14/2011 11:11:38 AM
Gravatar
Total Posts 18439

Re: Cloning the Forums Feature

If it fails to load the control it should log something in the log to give you a clue of the error.

Note that you must use a new featureGuid, new tables and stored procedures with different prefix, different .resx files, etc, nothing at all from the original feature should be used in the clone.

You will need to do a lot of find and replace in the feature code to change the namespaces and resource file references both in the .ascx, .aspx files and in the code behind files.

Hope that helps,

Joe

9/14/2011 11:22:44 AM
Gravatar
Total Posts 42

Re: Cloning the Forums Feature

Hi Joe,

Have done all that.

Followed the documentation to the letter.

Please see below log ( problem seems to be with ForumDisplaySettings)


2011-09-14 17:10:28,600 ERROR 10.101.5.202 - en-US - /home.aspx - mojoPortal.Web.UI.CmsPage - failed to load control CampusForums/ForumModule.ascx
System.Web.HttpParseException (0x80004005): Unknown server tag 'forum:ForumDisplaySettings'. ---> System.Web.HttpParseException (0x80004005): Unknown server tag 'forum:ForumDisplaySettings'. ---> System.Web.HttpException (0x80004005): Unknown server tag 'forum:ForumDisplaySettings'.
   at System.Web.UI.TagPrefixTagNameToTypeMapper.System.Web.UI.ITagNameToTypeMapper.GetControlType(String tagName, IDictionary attribs)
   at System.Web.UI.MainTagNameToTypeMapper.GetControlType2(String tagName, IDictionary attribs, Boolean fAllowHtmlTags)
   at System.Web.UI.MainTagNameToTypeMapper.GetControlType(String tagName, IDictionary attribs, Boolean fAllowHtmlTags)
   at System.Web.UI.RootBuilder.GetChildControlType(String tagName, IDictionary attribs)
   at System.Web.UI.ControlBuilder.CreateChildBuilder(String filter, String tagName, IDictionary attribs, TemplateParser parser, ControlBuilder parentBuilder, String id, Int32 line, VirtualPath virtualPath, Type& childType, Boolean defaultProperty)
   at System.Web.UI.TemplateParser.ProcessBeginTag(Match match, String inputText)
   at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
   at System.Web.UI.TemplateParser.ProcessException(Exception ex)
   at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
   at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
   at System.Web.UI.TemplateParser.ProcessException(Exception ex)
   at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)
   at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
   at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)
   at System.Web.UI.TemplateParser.ParseInternal()
   at System.Web.UI.TemplateParser.Parse()
   at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()
   at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
   at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
   at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
   at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate)
   at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath)
   at System.Web.UI.TemplateControl.LoadControl(String virtualPath)
   at mojoPortal.Web.UI.CmsPage.LoadPage() in C:\Code\Campus\Web\Default.aspx.cs:line 251

 

9/14/2011 11:32:12 AM
Gravatar
Total Posts 42

Re: Cloning the Forums Feature

Please what could be the problem with the ForumDisplaySettings control.

I'm quite clueless about it.

Hav spent several hours trying to clone.

9/14/2011 11:39:25 AM
Gravatar
Total Posts 18439

Re: Cloning the Forums Feature

Its a control implemented in the Forums at Forums/Controls/ForumDisplaySettings.cs

you would need to change the namespace in your version and also change the control declaration to your own namespace everywhere it is referenced. You'll need to look in all the .ascx and .aspx files for it. The one in the ForumModule.ascx has the tag prefix declared at the top like this:

<%@ Register Namespace="mojoPortal.Web.ForumUI" Assembly="mojoPortal.Features.UI" TagPrefix="forum" %>

then the control is declared like this:

<forum:ForumDisplaySettings ID="displaySettings" runat="server" />

the main purpose of this control is to provide a set of properties that can be configured from the theme.skin file to control various aspects of the rendering, ie it was implemented as part of mobile support so that the forums could render differently in mobile devices as specified in the theme.skin file of a mobile skin. The ForumDisplaySettings control itlelf does not render anything but other controls check its properties for configurations that control their rendering.

You'll need to look around and everywhere it is used you need to declare the tag prefix with your namespace and assembly name. You should also use a different tag prefix otherwise it may clash with existing declarations for the forums.

Hope that helps,

Joe

 

 

9/14/2011 11:44:36 AM
Gravatar
Total Posts 42

Re: Cloning the Forums Feature

Thanks Joe.

I appreciate the extremely swift response.

But, I have changed everything before even posting in this forum at all.

I have already done this for the blog feature, and followed the same steps successfully.

Your comments helped. Thanks.

Will continue to look.

9/14/2011 11:52:49 AM
Gravatar
Total Posts 42

Re: Cloning the Forums Feature

Oops!

Found the issue.

This line below still had mojoPortal.Features.UI.

<%@ Register Namespace="mojoPortal.Web.ForumUI" Assembly="mojoPortal.Features.UI" TagPrefix="forum" %>

I did a ReplaceAll to my own assembly, and it just works perfectly.

Sorry for the trouble.

Thanks all the same.

Maybe when I'm done, I'd consider contributing the extension, If it's standard enough.

9/14/2011 12:05:35 PM
Gravatar
Total Posts 42

Re: Cloning the Forums Feature

Got this error After creating a Forum, upon attempt to access it.

Sorry, you are not allowed to view this content. If you have questions about your permissions, please contact a site administrator.

Either you are not currently logged in, or you do not have access to this page within the site. Please contact the site administrator to obtain access.

 

I was logged in as administrator.

Even created a new user without admin rights, but still got the same error.

Please any ideas?

Thanks in advance.

9/14/2011 12:11:58 PM
Gravatar
Total Posts 18439

Re: Cloning the Forums Feature

Look in your cloned copy of Forum.cs in the business layer, change the featureGuid string constant there to match your new featureGuid

Hope that helps,

Joe

9/14/2011 12:39:51 PM
Gravatar
Total Posts 42

Re: Cloning the Forums Feature

Perfect.

Thank you Joe.

I truly appreciate this. It works fine now.

Would have loved to pop some champaigne over this, but I'm in Nigeria, and paypal does not have options for Nigeria, and Google checkout is disabled.

But please accept my appreciation.

 

 

9/15/2011 6:20:58 AM
Gravatar
Total Posts 42

Re: Cloning the Forums Feature

Hi Joe,

Saw this in the roadmap for the Forums feature.

    Sticky threads - completed
    option for pre-moderation of posts before they are visible
    ability to mark posts as questions and vote posts as answers

1. Please what are "Sticky threads", and what are they used for?

2. I actually intend to try and extend the forum such that one will be able to add comments to Questions/Responses, and also vote on questions. recall that I've asked about this before... in this post

Any advice on the best way to implement this will be appreciated.

3. In the code, I discovered that "mp_" is hard-coded, so the custom forum I cloned is creating entries in the original mp_ tables, even though I changed this in the install script. Do I have to replace all these in the code also? If yes, I'd suggest that the documentation be updated a little to include this, cos it just said to do the replace in the install scripts.

Thanks.

9/15/2011 6:32:30 AM
Gravatar
Total Posts 18439

Re: Cloning the Forums Feature

Hi,

1. sticky threads have a higher sort than other threads, for example we have a sticky thread about important skin changes, it stays at the top of the thread list in the design/skinning forum. It is also a locked thread so only users with page edit permissions can edit it or post on that thread.

2. sorry I have no advice on that its too general a question

3. yes of course you need to change it in your cloned DBForums.cs, for every method you must change that prefix to match your stored procedures so it will use your tables, I just updated the document.

Hope that helps,

Joe

9/15/2011 6:52:50 AM
Gravatar
Total Posts 42

Re: Cloning the Forums Feature

Thanks Joe.

The response speed still beats my imagination.

Regards.

9/15/2011 8:41:47 AM
Gravatar
Total Posts 42

Re: Cloning the Forums Feature

I have an update.

Came upon an error.

In the Install Script, there are some references to the mp_Users table.

If you do a "Replace All" from mp_ to joe_(or your own custom prefix), references to mp_Users will also be renamed.

In my own case, I had to go and manually rename this in the stored procedures already created (espectially the ones that had to do with select).

However, one can actually do another "Replace All" from e.g. joe_Users back to mp_Users before running the scripts and all will be fine.

If there are any comments/objections to this, kindly update all.

Regards.

9/15/2011 11:19:34 AM
Gravatar
Total Posts 42

Re: Cloning the Forums Feature

Dear Joe,

Sorry for my trouble.

Thanks for your help so far.

This part of code is having an IndexOutOfRangeException(pls see highlighted part below).

This portion is in the ForunThread class.

Seems there's a problem with "ModuleID".

I drilled down to the stored procedure cmp_ForumThreads_SelectOne, it seems "ModuleID" is not part of the fields returned.

Kindly assist.

 

private void GetThread(int threadId)
        {
            using (IDataReader reader = DBForums.ForumThreadGetThread(threadId))
            {
                if (reader.Read())
                {
                    this.threadID = int.Parse(reader["ThreadID"].ToString());
                    if (reader["ForumID"] != DBNull.Value)
                    {
                        this.forumID = this.origForumID = int.Parse(reader["ForumID"].ToString());
                    }
                    if (reader["ModuleID"] != DBNull.Value)
                    {
                        this.moduleID = this.origForumID = int.Parse(reader["ModuleID"].ToString());
                    }

9/15/2011 12:01:29 PM
Gravatar
Total Posts 18439

Re: Cloning the Forums Feature

Once you clone a feature it is up to you to be able to solve and problems you have with it. The original forum does not have an error there and the stored procedure mp_ForumThreads_SelectOne does return that field.

Possibly your work on the scripts did not produce a correct result. I would have generated a script for the tables and related procedures based on the latest version of the existing feature as it exists in the db, then I would have modified the script to change the prefixes as needed on the tables and procedure names. I'm guessing you used the complete history of upgrade scripts rather than just generating your own, but somehow you either did not get all of them or are missing some changes or upgrade scripts. For a simple feature with only a few scripts it can work to copy and modify the series of scripts for the original feature but for a feature that has a long upgrade history you are better off making your clone start out with a single installation script that is up to date with the latest schema rather than replicating the entire upgrade history of the old feature.

Hope that helps,

Joe

9/17/2011 10:03:36 AM
Gravatar
Total Posts 42

Re: Cloning the Forums Feature

Thanks Joe.

I discovered that the issue was that f.ModuleID was not in my own customized stored procedure (mp_ForumThreads_SelectOne). I added this, and the issue resolved.

However, i checked the original script, f.ModuleID was not part of the script.

I wonder how this field got created in the stored procedure.

Anyway, the issue is now resolved.

9/17/2011 10:18:37 AM
Gravatar
Total Posts 18439

Re: Cloning the Forums Feature

The forum has an installation script and a number of upgrade scripts.

For a new installation it will first run the highest script version (0.0.1.6) from the folder

/Setup/applications/forums/SchemaInstallScripts/mssql/0.0.1.6.config

after that it will run all the scripts with a higher version in sequence from

/Setup/applications/forums/SchemUpgradeScripts/mssql/

starting with 0.0.1.7 and continuing through 0.0.2.0

the 0.0.1.9 script is the one that updated the procedure mp_FuromsThreads_SelectOne to include ModuleID

So when cloning a feature one could copy and modify all the upgrade scripts but if there are a lot of them it can be cleaner to generate your own up to date script based on the current schema rather than replicating the upgrade history of the original feature.

Hope that helps,

Joe

9/17/2011 2:27:21 PM
Gravatar
Total Posts 42

Re: Cloning the Forums Feature

Yes. Thank you.

That helps a lot, and also clarifies many things.

Thanks for your time and assistance.

You must sign in to post in the forums. This thread is closed to new posts.