Showing posts with label WebPart. Show all posts
Showing posts with label WebPart. Show all posts

Friday, 4 November 2011

Collabse Comment Field in Listview

 

You can collabse the command field of a list view webpart in the following way:
  1. Open your page which contains the listview webpart (and the command field) in SharePoint designer
  2. Right click the webpart (page is open in SharePoint designer) convert to XSLT Data View in SharePoint designer.
  3. Save the page from SharePoint designer
  4. Open the page in the browser
  5. Choose WebPart properties >> XSL Editor
  6. Locate the line: <Xsl:value-of .../> for the V3Comments field
  7. Replace the line by:
  8. <SharePoint:AppendOnlyHistory runat="server" ItemId="mailto:%7B@ID}" FieldName="V3Comments" ControlMode="Display" />
  9. Apply the changes

Cannot Remove WebPart

Cannot Remove WebPart

It could be possible (in some situation) that it is inpossible to delete a WebPart from a Page. E.g. you inserted some javascript in a content editor webpart (HTML view). This Javascript makes the page causing a bug and the page wil return an error (so you can't edit the page). Simply add ?contents=1 after the url: e.g. on the default page http://mysharepointurl/default.aspx?contents=1
Now you can delete the webpart which is causing the error:
 

Create Master Detail View of Custom Lists using WebPart Connections

 

Sometimes you want to have to lists, if you click on a record in the one list (e.g. name), you want details about that record (e.g. hollidays from that specific person). One of the options is to use Out of the Box WebPart Connections in SharePoint to realize this.
First I created two custom lists with the follow coloumns:
Custom List: Employees

Custom List: Holliday

  1. Next step is to pass this to lists on a webpart page. With the employee list webpart on top.
  2. Select Modify Shared WebPart (of the employeelist webpart) > WebPart Connections > Provide Row To > Holliday

In the next screen choose "Last Name"

Now you can select a row from the top (employee) tabel you get details in the bottom (holliday) table

Thursday, 3 November 2011

RSS Feeds Web Part


Steps:
1. Add a XML web part to a share point page where you want to add the RSS Feeds web part.
2. Edit the properties of the web part.
3. In the XSL editor place the code (given below).
4. In the XML link give the proper RSS feeds URL.
5. Click Save.
6. This will display the RSS feeds from the URL linked in the web part.

Code:<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<div>
<xsl:apply-templates select="rss/channel"/>
</div>
</xsl:template>
<xsl:template match="rss/channel">
<xsl:variable name="link" select="link"/>
<xsl:variable name="description" select="description"/>
<ul><xsl:apply-templates select="item"/></ul>
</xsl:template>
<xsl:template match="item">
<xsl:variable name="item_link" select="link"/>
<xsl:variable name="item_title" select="description"/>
<xsl:if test="position() &lt; 6">
<li>
 <a href="{$item_link}" title="{$item_title}"><xsl:value-of select="title"/></a>
 </li>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

News Aggregator web part


This blog posting applies to Microsoft Office SharePoint Server 2007.
This topic describes a way to configure SharePoint elements for displaying headlines and abstracts from news articles, aggregated across many sites.  Also a description of customizing the page layout of the news article is given.

Displaying the news headlines:


When clicking on the headline in the web part, the user is taken to see a typical news article:

Elements of this Approach

  1. Custom Content Type to provide aggregation target.
  2. Custom Page Layouts to provide controls for aggregation plus custom look and feel.
  3. Custom Web Part (Content By Query) to display desired news in desired format/behavior.

Prerequisites

Site where news pages are created must have Publishing feature activated.
Site Settings à Site features à Office SharePoint Server Publishing [Activate]

1. Custom Content Type

Create a new Site Content type on the top-level site (corporate intranet site)
Call it Adatum News Article, make its parent type an Article Page (from the Page Layout Content Types), and put it in the Adatum Content group.  If this is the first member of the group, then you will have to make a New group with this name as shown in this sample:

 

2. Custom Page Layouts

Using SharePoint Designer, open the top-level site, and open the MasterPageGallery (in the _catalogs folder).  Copy several layout files and rename the copies such as in the following sample:

Existing layout file
Copied layout file
ArticleLeft.aspx
AdatumArticleLeft.aspx
ArticleLinks.aspx
AdatumArticleLinks.aspx
ArticleRight.aspx
AdatumArticleRight.aspx

Associate with Custom Content Type

After copying the custom layouts, associate the custom content type with each one.  Using the SharePoint Site Settings, click Master Page and Page Layout Galleries, and you should see the new custom layouts that you added.  Edit the properties of each one to set the associated content type; select the custom type that you created, such as shown in the following sample:


The Title property is the string that will appear on the page layout when a user edits the page to create or modify news.

The Description property is the string that appears when people are choosing the format for their news article.

The Preview Image property allows you to specify an image that is shown when people are choosing the format for their news article.  End users really like thumbnails, so it will help to finish customizing the custom layout page and then create a sample article that you can take a screen shot of and turn into a thumbnail.  This preview image is rather large (220x140) and can be a jpg or gif, so you can get some detail to show.

The Associated Content Type property should be set to the custom content type that you created.  This will allow the news aggregator to find this article quickly.

Customize the Page Layout

At this point, you don’t have to do any further customization in order for the news aggregation scenario to work.  But

Add a Description Control

The Content By Query web part that we’ll use for our news aggregator has several different viewing formats available.  Several of these show the Description property of the news article page.  Unfortunately, there is not a control to enter the description on the page layout; to modify this out-of-box you have to edit the properties from the page library view.  But we can easily add a control to the page layout to provide an input field for the description property, and this makes it much more useful for people writing news articles to show an abstract for the article.

Check out and edit each of the copied layout files to add two items: a NoteField control for the Description field, and an EditModePanel to show instructions for the Description field.  Put these controls into a new row in the table containing the date and byline, as shown below.


The following sample shows a new page that has been created with the customized page layout.  You can see the additional Description field


At this point, you are ready to create new pages with this layout.

Create a new page with this layout

This step is an example, it is not necessary to create the masters.  Go to a site in the hierarchy of the portal that has the Publishing feature activated.  By default, the Corporate Intranet Site and the Team Publishing Site have this feature, but it is easy to activate for other sites as well.

Under Site Actions, click Create Page, and select the new custom layout, as shown below.


3. Custom Web Part – the Aggregator

Add a Content Query web part to the page, and set it to Show items from all sites in this site collection.  Then set the List Type to Pages Library, and the Content type to Adatum News Article in the Adatum Content type group, as shown below.


Other configurations include Filtering, Sorting and Styles under the Presentation header.  Choose what is suitable; the examples here sort by Article Date descending, set the Group style to “small text”  and the Item style to “Image on right” which tends to look better when there is no rollup image for the article.  A generic Adatum news logo was created for people to use when they don’t have a rollup image, or they could leave that blank.

Once the look and feel is acceptable, export the web part so you can use it in other places.

Further Customizing the Look and Feel

XSLT can be used to make additional customizations to the views available to the Content Query web part.  This can be used for several other techniques:
  • Show the first X characters of the news item as the abstract instead of using the Description field
  • Open news items in a new window.
  • Show other metadata from the news item.
I was all set to show a simple example that you could extend, but then found Steven Van de Craen's  excellent, detailed instructions for doing this.  See his blog entry at SharePoint 2007 Beta 2: Customizing the Content Query Web Part XSL.

Behavior

Another challenge for most approaches is allowing the user to read the news without taking their browser to the site where the news is published, since some people claim this causes confusion.  Further, it will be desirable to have a link to allow the person to visit the site where the news is published if that’s what they want.  Both of these can be accomplished using the XSLT techniques referenced above.