Showing posts with label Discussion Board. Show all posts
Showing posts with label Discussion Board. Show all posts

Tuesday, January 1, 2013

Insert smileys and Thanks button for SharePoint Discussion List


Some days ago, after I worked on my forum (sharepointvietnam.net) I found the Mod that is very useful. It called Thank Mod. If you read a topic or reply a post and it helped you somehow to solve a problem, you will say “Thank you” and on community or forum you may click on Thank button an you only can say thank for one time on the post.
SharePoint Discussion List has the functioning similar to forum of vBulletin or phpforum. However, SharePoint Discussion List just limited the functioning on creating the topic and other users can reply on the topic. To expand or plug into this list much more features it’s not easy and if you need it to be have fully features like others forum, let build a project then add the existed featured from my topic and from others on the internet. In my topic, just there are 2 small features: insert smileys and thank button, just ask Mr/Mss Google to get more functionalities.
Two features in this topic are here:

Please read carefully my topic before deploy or install:
  • Backup these files in HIVE\14\Templates\Layouts\XSL: main.xsl, thread.xsl, vwstyles.xsl and internal.xsl because these files will be replaced the original after installed. If this feature or solution is removed then these files will also be removed out of the folder. Now, just restore them from a backup folder.
  • After install/deploy, run the command iisreset and create the new discussion list to get the effected.
To insert smiley:
Click on the editor area then the contextual ribbon would appear and click on Insert tab


Click on Smileys button, the popup will show on top:

Click on the icons to pick-up one or more icons which would be inserted into the topic.
There is a thing you should pay attention for the upgrading in future: you could see 4 tabs on the popup window, that is because there are 4 emotion folders in Emotion Project folder. You could find them in HIVE\14\Features\EmotionProject

For now, think about how to install or remove one or more emotion categories and the answer is so easy, just create a folder as category and copy all emotion files to the folder. Then, re-open the popup window smileys it would be updated immediately.
Notice: do not click on the checkbox, just click on the icon, the checkbox will be changed the status automatically.
In addition, you can say thank to the owner of topic by click on Thanks button:

If you have never click on Thanks button for the post, you will see Thanks button and other people say thank to the owner of the post. Ater click Thanks button, your friendly display name will appear under the line and you could not say Thanks again for that post, and you also could not remove your thanks in the thanks list, so let pay more attention or think much more about the post to say Thanks or not. It may have a difference thought from Facebook like button, you can remove (unlike) a status if you have a difference mind.
Thanks button will only appear on both Flat view and Thread view. If you need the thanks button appear on your customize view, please add the code to your xsl file render:

In the project, I used the jQuery library and if there is any conflict with your product, please remove my jQuery library and used yours, that’s not important and work as well.
Good luck to you.

Monday, January 24, 2011

How to get all items of Discussion Board list using Web Service.

Hello everybody,
I am working on Discussion Board list using Web Service. I am so supprised that the DB list is not the same as another list in SharePoint. The first sign of my mind is Calendar List Item, SharePoint stores the StartDate & EndDate with a different ways. To get the correctly data, we must understand clearly about architecture of Calendar list.

For now, the problem about Calendar was solved and faced to another problem. Discussion Board list has 2 item types: Dicussion (threads) and Message (replies). When you get all items by normaly, you only get the discussion items, take a look at code:


            XmlDocument document = new XmlDocument();
            XmlNode query = document.CreateNode(XmlNodeType.Element, "Query", "");
            
            XmlNode viewFields = document.CreateNode(XmlNodeType.Element, "ViewFields", "");


            XmlNode queryOptions = document.CreateNode(XmlNodeType.Element, "QueryOptions", "");
            queryOptions.InnerXml = "<ViewAttributes Scope='RecursiveAll'/>";


            Lists lists = new Lists(URL_SERVER);
            lists.Credentials = CredentialCache.DefaultCredentials;
            
            XmlNode node4 = lists.GetListItems(sourceList, "", query, viewFields, "", queryOptions);


Okey, even thought Scope attribute is set to "RecursiveAll", and SharePoint 2007 works fine. All items including reply items are list. But it does not work in SharePoint 2010, so it is not actually difficult to fix for SharePoint 2010. Just update your query CALM like the code below:


query.InnerXml = @"<Query>
                                <Where>
                                    <Geq>
                                        <FieldRef Name=""DiscussionLastUpdated"" />
                                        <Value Type=""DateTime"">1900-01-01T00:00:00Z</Value>
                                    </Geq>
                                </Where>
                               </Query>";
Yes, that's it.

Tuesday, July 27, 2010

SPSiteDataQuery error on Discussion Board List

SPSiteDataQuery is used to get the data from multiple list with the same type. The code below shows how to get all items in Discussion Board List. Only show Subject and ID after returning data.

SPSiteDataQuery query = new SPSiteDataQuery();


query.ViewFields = "<FieldRef Name=\"LinkDiscussionTitle\"/><FieldRef Name=\"ID\"/>";
query.Lists = "<Lists ServerTemplate=\"108\"/>";


DataTable table = web.GetSiteData(query);

But you will get an error like this:


AAAAA.Data.UnitTest.GetInternalName.GetDataFromDB : Microsoft.SharePoint.SPException : Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))
  ----> System.Runtime.InteropServices.COMException : Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))


The details:



 at Microsoft.SharePoint.Library.SPRequest.CrossListQuery(String bstrUrl, String bstrXmlWebs, String bstrXmlLists, String bstrXmlQuery, ISP2DSafeArrayWriter pCallback, Object& pvarColumns)
   at Microsoft.SharePoint.SPWeb.GetSiteData(SPSiteDataQuery query)
   at Bamboo.Data.UnitTest.GetInternalName.GetDataFromDB() in D:\BambooFolder\TFS2008\Bamboo.WP.ListConsolidator\Bamboo.ListConsolidatorSoln\Bamboo.Data.UnitTest\GetInternalName.cs:line 168
--COMException
   at Microsoft.SharePoint.Library.SPRequestInternalClass.CrossListQuery(String bstrUrl, String bstrXmlWebs, String bstrXmlLists, String bstrXmlQuery, ISP2DSafeArrayWriter pCallback, Object& pvarColumns)
   at Microsoft.SharePoint.Library.SPRequest.CrossListQuery(String bstrUrl, String bstrXmlWebs, String bstrXmlLists, String bstrXmlQuery, ISP2DSafeArrayWriter pCallback, Object& pvarColumns)


The LinkDiscussionTitle is one of the internalname of Discussion Board List, but if you try to query by that column, you will get an error. You can query by any column, except for LinkDiscussionTitle. Just remove that column out your query string, it works fine.

SPSiteDataQuery has been supported all functions like SPQuery exception for GroupBy, if you try to put the GroupBy clause into query, it will throw exception but you can work with filtering and sorting.