PANVEGA’s Blog

DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

Archive for the ‘WebParts’ Category

Custom SharePoint Page Counter

Posted by PANVEGA on September 7, 2009

In this post I show you how easy it is to develope a custom Page Counter Webpart in Visual Studio.

In one of my older post I explaid how to add Counter Web Component to your page by using the SP Designer. However this approach has some disadvantages.

https://panvega.wordpress.com/2009/06/22/how-to-add-a-hit-counter-to-a-page

Steps to do:

  1. Create a new Custom Field for instance PageCounter
  2. Add this custom field to your Page ContentTypes by using a FeatureReceiver Class
  3. Create a Webpart project
  4. Access the Pages List and parse all pages.
  5. increment the custom PageCounter filed
  6. Incremt just in Publish Level Mode
  7. do a item and list update Read the rest of this entry »

Posted in C#, MOSS, WebParts | Tagged: , , | Leave a Comment »

Easy Grouping in XSLT 1.0

Posted by PANVEGA on June 10, 2009

I was asked to implement a grouping by TEAM with all the employees regarding to the Team Name into a SharePoint People Results Webpart. Here I am gonna show you a very nice aproach how to realize this custom request.

I read in so many posts how to create a proper grouping results in XSLT 1.0. XSLT 2.0 makes grouping even easier than Steve did. The XSLT 2.0 xsl:for-each-group instruction iterates across a series of groups, with the criteria for grouping specified by its attributes.  While XSLT 1.0 lets you sort elements, it still forces you to jump through several hoops to do anything extra with the groups that result from the sort.

Here is a snipped of the XML file:

<?xml version="1.0" ?>
<All_Results>
 <Result>
  <Team>BI</Team>
  <PreferedName>Alex</PreferedName>
  <Function>1</Function> 
 </Result> 
<Result>
  <Team>BI</Team>
  <PreferedName>Max</PreferedName>
  <Function>3</Function>
 </Result> 
<Result>
  <Team>BDEV</Team>
  <PreferedName>Moritz</PreferedName>
  <Function>1</Function>
 </Result>
</All_Results>
 Read the rest of this entry »

Posted in MOSS, WebParts, XSLT | Tagged: , , | Leave a Comment »

Adding a Property to the Advanced People Search and a Column to the People Result Webpart

Posted by PANVEGA on June 9, 2009

A customer asked me to adding a Property Field called “Manager”  in the People Search Advanced Mode. For this demonstration I added  custom property called “Manger” to the profile properties, and in the following walkthrough I will show how to add searching on that property to the advanced search screen of the people search. In addition how to add this new field the your Search Core Results Webpart results. Tis how to is devided in 2 main parts. Read the rest of this entry »

Posted in Administration, MOSS, WebParts, XML, XSLT | Tagged: , , , , | 6 Comments »

Custom Table Format with the SP HTML Webpart

Posted by PANVEGA on June 2, 2009

When editing content in a SharePoint Publishing site, you can select from 5 predefined table formats when inserting a table. The image on the left lists the table formats available to select from. Although the table formats are worth consideration, they may not match the unique fonts, colors, and other branding defined elsewhere within your web site.

Microsoft Office SharePoint Server 2007 includes an advanced Rich Text Editor that supports predefined table formats. The Rich Text Editor in SharePoint Server 2007 reads the predefined table formats from cascading style sheets that are linked to the page.

You can view the OOTB styles by going to “http://yourportalsite/_layouts/1033/styles/HtmlEditorTableFormats.css


TableTemplate

Read the rest of this entry »

Posted in CSS, MasterPage, MOSS, WebParts | Tagged: , , , | Leave a Comment »

Custom CSS Styles in the SP RichText Editor DropDown

Posted by PANVEGA on May 26, 2009

When creating content on a publishing site through a Page Content HTML editor there are some basic styles that come OOTB: The styles are actually conditional and different styles appear based on the type of content selected. Create your own set of standard header and section styles that are easily available to your content authors directly within the content editor.  These styles appear in the seldom-used “Styles” menu within the content editor toolbar.  By default, you’ll notice this menu is populated with three header styles that are just about everything but useful. Read the rest of this entry »

Posted in CSS, MasterPage, MOSS, SPDesigner, WebParts | Tagged: , , , | 1 Comment »

SP CQWP custom ContentQueryMain.xsl

Posted by PANVEGA on March 20, 2009

I would like to get the web part title in the Contentquerymain.xsl.  I don’t want to put the title in the normal web part header, because it will modify all web parts headers and I only want to modify the CQWPs ones.

Here I described a way how to add any functionality to your CQWP. You can create your own version of the ContentQueryMain.xsl file that you can use for that specific web part.

Introduction:

While customizing the ItemStyle.xsl stylesheet is a quick and easy way to stylize your rollups and other output, it doesn’t really give you the ability to make any major changes to the structure or behavior of the CQWP. To do this, you’ll need to modify the stylesheet titled “ContentQueryMain.xsl,” which is located in the same folder as the ItemStyle.xsl file (/Style Library/XSL Style Sheets/). The problem with modifying the ContentQueryMain.xsl file is that any changes you make to this file will affect all CQWP’s site-wide. That’s not desirable in just about any situation, so you’ll have to create your own version of the ContentQueryMain.xsl file that you can use for that specific web part. Read the rest of this entry »

Posted in MOSS, WebParts | Tagged: , | 7 Comments »

CQWP Remove Markup from escaped page content

Posted by PANVEGA on March 18, 2009

I created a CQWP Template for displaying Items with some formatted Rich-Text Content. Nothing special. In addition the Rich-Text Description field should only display the first 180 letters and here is the small issue. An advanced Rich-Text field creates a div class around each content.

<div class=ExternalClassD7864B0CF5B14386AF6CB349205DC792> <div><font size=2>documental que toda compañía precisa: Flujos en Serie Flujos Paralelos (varios aprobadores) …

Read the rest of this entry »

Posted in MOSS, WebParts, XSLT | Tagged: , , | Leave a Comment »

Customizing Styles of Table of Contents WebPart (TOC)

Posted by PANVEGA on February 11, 2009

I this post I gonna show you how easy it is to customize the default Tabel of Contents Webpart. This webpart can list pages, lists and subsites of a specific site, and this in a custom organization and presentation. When using it on the default master page, it shows the content in different levels with some nice indentation applied to it. The main modification is to the XSLT that the web part uses when rendering the contents.

the TOC Web Part consists of the following files to amend:

  • Header.xsl
  • LevelStyle.xsl
  • TableOfContentsMain.xsl

The solution  is adding custom CSS styles unit to the xsl templates. Luckily, the table of contents is one of those webparts which uses XSL style sheets to format its data and makes those available in the Style Library within your SharePoint site collection. Once inside this style sheet (LevelStyle.xsl), one can easily be edited to the different styles. Read the rest of this entry »

Posted in CSS, MOSS, SPDesigner, WebParts, XSLT | Tagged: , , , , | 9 Comments »

Approaches when customizing a DataView WebPart (DVWP)

Posted by PANVEGA on February 7, 2009

In this post I wanna show some tricky approaches when customizing  DataView Webparts (DVWP) in the SP Designer. Maybe the approaches can save you a lot of time. Actually you can customize the weparts view how ever you wish. Customize the Filtering, Grouping and Sorting values in the dvt_1.toolbar template. Present the information with your own CSS classes. Replace the default .ms-toolbar class in the core.css.

Creating the initial dataview can be done on a virtual machine, so there is no risk of breaking anything (and development is easier when you don’t have to deal with the VPN). In SharePoint Designer, create a dataview on any list and convert it to xsl. Don’t make any changes before the conversion, as the conversion doesn’t always work that well.

Introduction:

Microsoft Windows SharePoint Services provides the powerful Data View Web Part that can perform an Extensible Stylesheet Language Transformation (XSLT) on XML data retrieved from a data source. When you are working with a Web site based on Windows SharePoint Services from within Microsoft Office FrontPage 2003, you can use the Data View Web Part to do the following:

  • Define a query and data source from which to retrieve the XML data. Data sources can be SharePoint lists or external databases such as Microsoft SQL Server.
  • Define the XSLT transformation that converts XML retrieved from the data source into HTML. FrontPage offers a WYSIWYG experience for editing these XSLT views, including live data preview. Read the rest of this entry »

Posted in MOSS, SPDesigner, WebParts, XML, XSLT | Tagged: , , , , | 7 Comments »

Adding a Webpart into a MasterPage with a Feature

Posted by PANVEGA on January 16, 2009

The best practise, when you want to add a Webpart into a MasterPage is using a Delegate Control with a Feature.  I wanted to add a Content Query Webpart into my Masterpage Page headline with a Custom Delegate Control.  Note!  You can not add a Webpart Zone into a MasterPage just static Webparts!  Many of the controls used on default.master are loaded using the Delegate Control. These include global links such as My Site/My Links and the publishing console. So using this approach, customizing the publishing console is a simple matter of providing a replacement .ascx and creating a feature as described here!

Why using a Delegate Control?

Using the concept of a delegate control, you can take any control that exists in Sharepoint today or your own custom creations and place them on a sharepoint page such that they override the existing control at whatever scope you desire (individual site, site collection or farm) and yet require no recoding of the page(s) itself.  In previous Sharepoint versions, this involvded either customizing the pages one by one and/or creating a whole new site defintion. With the concept of delegate controls in Sharepoint 2007, its a handful of lines of code and its far more powerful.

On every Sharepoint deployment I have ever done, it has been requested that the search box be modified, either comsmetically or functionally.

Here is a short example:

<SharePoint:DelegateControl runat=”server”
ControlId=”SmallSearchInputBox”/>

The delegate control tag, the best I can deduce, does a lookup of the features on the site that will share the controlID value of “SmallSearchInputBox”. Out of the box, there is only 1 of these declared, in the feature called ContentLightup.

What you can do (as documented in the SDK) is create your own feature that uses this same controlID but refers to a different underlyling .ascx (custom control) file. The delegate control feature will then check the list of all controls with this same ID and use the one that has the lowest sequence number as declared in the <control> tag as part of another xml file in the feature

<!– using a sequence number LOWER than default of 100 so our custom control gets loaded –>

<Control
Id=”SmallSearchInputBox”
Sequence=”61″
Controlsrc=”~/_controltemplates/searcharea.ascx” mce_src=”~/_controltemplates/searcharea.ascx”>
</Control>

Only thing to note here at this stage is the ControlId attribute – the Feature we create will use this to substitute the real user/server control.

Read the rest of this entry »

Posted in Delegate Controls, Deployment, MasterPage, MOSS, WebParts | Tagged: , , , , | Leave a Comment »

Create a rotation banner in a CQWP

Posted by PANVEGA on January 13, 2009

In this post I am gonna explain how easy it is to create a custom banner function in a CQWP by adding some JavaScript code. The goal is to show a Title with a hyperlink and a short description in a rotation banner function. The Content will be referenced from a Custom SP List with these fileds. Read the rest of this entry »

Posted in Delegate Controls, JavaScript, MOSS, SPDesigner, WebParts | Tagged: , , , , , | Leave a Comment »

Introduction in the Content Query Webpart

Posted by PANVEGA on January 7, 2009

Microsoft Office SharePoint Server 2007 introduces a lot of new web parts, one of them being the Content Query Web Part. This Web Part is part of the “Web Content Management” features of Microsoft Office SharePoint Server 2007 and in order to use it you need to turn on the Publishing feature on a site. It is not available in a default Windows SharePoint Services v3 installation.

Using the Content Query Web Part you can display a dynamic view of content from your site on a web page. The web part can be configured to retrieve items from a single list, a single site and subsites or the entire site collection. It builds a CAML (Collaborative Application Markup Language) query and uses the new Microsoft.SharePoint.SPSiteDataQuery class to query the server. Filtering, sorting, ordering and grouping can all be configured in the Web Part properties.

Displaying the results can be done by choosing one of the default item layout styles. The default item layout styles cover basic formatting with bullets, images and font size.

default layout
Content Query Web Part: default layout

Read the rest of this entry »

Posted in MOSS, WebParts, XSLT | Tagged: , | 5 Comments »