MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Displaying List of new messages/topics  (Mono Support )

Viewed 9615 time(s), 6 post(s) 2/10/2014 4:31:33 AMby sam0864
sam0864

sam0864

2/10/2014 4:31:34 AM
I am trying to build question/answer forum. I would like to display the list of the new topics (including the topic post) regardless which discussion board. Similar to "New topics" link but I would like to display the first post instead of the last one and show the whole post

Here is an example
http://stackoverflow.com/questions/tagged/Java
This content has not been rated yet. 
656 Reputation 79 Total posts
mzilic

mzilic

2/10/2014 10:23:49 AM
Hello,

The following would require some changes to the forums module so first I need the following information.
Can you tell us if you're using the MonoX free edition or the source code edition? Have you setup a custom project based on this Blog post: http://www.mono-software.com/blog/post/Mono/95/Building-a-custom-ASP-NET-project-based-on-MonoX/? Do you also plan to use the standard MonoX forums as well?

Regards,
Mario
This content has not been rated yet. 
2218 Reputation 300 Total posts
sam0864

sam0864

2/10/2014 12:44:08 PM
I am using the latest free version. Yes, I have the custom project setup.
I am planning to keep the standard forum (unless it is too hard). I am OK if I can replace the view of the new topics to show the first post of the new topics instead of the last one and show the whole post
This content has not been rated yet. 
656 Reputation 79 Total posts
mzilic

mzilic

2/10/2014 1:49:02 PM
Ah, OK.

The easiest way I can think of is to do the following:
1. Inherit the DiscussionTopics control
2. Create a new method to fetch the first discussion topic message (in discussion topics ParseTemplateTags method you have the Discussion Topic Id which you can use to fetch the discussion messages)
3. Override the ParseTemplateTags in the DiscussionTopics control
4. In the ParseTemplateTags you need to populate the following tags with new information. Over here you need to use the new method to fetch the first post which you've created and use is to populate the relevant tags. The tags which are related to the posts are below:
"<# LastPostText #>" This is the string which contains the "Last post by" caption. You could replace it with your own.
"<# LastPostToolTip #>" This contains the tooltip of the last post. You can either cut the content or include the whole post. This is the Message property of the DiscussionMessage entity.
"<# LastPostName #>" This is the message of the post. It's the same as the LastPostToolTip property. If you don't trim the content over here the whole post will be shown.
"<# LastPostUrl #>" This is the url of the post. You can use the GenerateMessageUrl method to generate the URL of the post.
"<# LastPostDate #>" This is the info when the last message was posted. You will also as well want to change that or even hide it. If you want to hide it you can use the following:
velocityContext.Put("LastPostVisible", false);
5. After you do that you can modify template of the discussion topics. Please understand that changing the template will also be reflected on the other discussion topic modes. If that doesn't suit you you could create a new template and use that template for new topics posts only for example. You can use the TopicFilterType property in the DiscussionTopics control to detect the currently active mode.

Depending on your requirements you could replace the new DiscussionTopics control with the old one or you can use it as a separate web part.

Regards

This content has not been rated yet. 
2218 Reputation 300 Total posts
sam0864

sam0864

2/14/2014 7:06:04 AM
I thought it could be done as simple as updating DiscussionTopic template and use different tag instead of <# LastPostName #>

 Do you have a sample code I can use?
This content has not been rated yet. 
656 Reputation 79 Total posts
mzilic

mzilic

2/14/2014 11:52:33 AM
I thought it could be done as simple as updating DiscussionTopic template and use different tag instead of <# LastPostName #>
You can, my response was based on the premise that you would replace the new topics view as you said it yourself.

I am OK if I can replace the view of the new topics to show the first post of the new topics instead of the last one and show the whole post
The approach I described will do just that. However you can always use the same approach and add a new tag in the App_Templates theme file and use the same approach described here to add a custom tag. The templates are being loaded and replaced by controls or text at runtime (with whatever is defined in the ParseTemplateTags method). We also have support for NVelocity which in turn has a Container object which allows you to use for example $Container.DataItem.Message in the templates themselves and using this you could essentially avoid overriding the ParseTemplateTags method however the module you want to override doesn't provide you with the first post information and you will have to use the approach I described. You can learn more in khorvats post about NVelocity Container: http://www.mono-software.com/Mono/Pages/Discussion/dtopic/ga55ojHry0et6aLRANcHwQ/How-to-display-name-instead-of-username-when-publishing-posting-in-forum-etc/?dmsgId=gpbNO-5yd0qFbqLRARQ2rg#PostgpbNO-5yd0qFbqLRARQ2rg

Do you have a sample code I can use?
The approach of adding a new tags is the same as the approach I described earlier. Only instead of overriding MonoX tags you will just add the new ones into the collection.

This content has not been rated yet. 
2218 Reputation 300 Total posts