HiddenNetwork.com Banner
Showing posts with label SharePoint Designer. Show all posts
Showing posts with label SharePoint Designer. Show all posts

Friday, May 11, 2007

SharePoint Designer Article 2 - Creating an XSLT DataView for a sharepoint list

An XSLT dataview is a great way to modify the look and feel of displayed data in a sharepoint site. The dataview web part is able to display data from either sharepoint lists, or from external data sources.
This article will focus on how to create a simple xslt dataview for a sharepoint list.

First we will create a sharepoint list - Contacts, and fill it with some sample data:


Now, lets create a new page that we will use to create the xslt dataview in:


Open the page in SharePoint Designer (see my previous article if you forgot how - you will need to detach it from the page layout first!).


Now we can add the contacts list to the page using sharepoing designer. You can also do that from the browser before opening the page in sharepoint designer if you prefer:


Let us work in a clean environment - change the properties of the web part so it doesn't display the toolbar. Annoyingly, in sharepoint designer this means you have to open the dropdown menu for the web part (looks like a list icon) and select "change layout":


Select not to show a toolbar.
Now we can transform the web part to an XSLT dataview. Just right-click the web part and choose "convert to xslt data view":


The page should flash and then the web part will appear again, only slightly different. A new menu will appear with a lot more options (filter, sort and group, paging, edit columns, change layout, data view preview, show with sample data, conditional formatting, web part connections, parameters, refresh dataview, dataview properties).
Now you can start playing with it!

In this article I will not go over all the options - I will just conclude by showing you the conditional formatting, and how to deploy the web part to another page in the site:

Click on "Conditional Formatting" in the common data view tasks menu:


The task pane on the right should change to the "Conditional Formatting" pane. Now we can click a row (any will do), and then click the "create" menu, and choose "apply formatting" from the menu:


Because we selected a row, we can apply formatting to that row based on rules we will now define in this screen:


In this example I chose the rule - when first name is "Ishai". Press OK to get to the formatting options:


I set the formatting to show my contact's row with a light blue background, in bold and in uppercase.
Save the file, and view it in the browser:


As you can see - it shows exactly what I wanted it. Now to deploy it to the home page of the site (which we didnt want to detach from the layout page):
In the browser, open the actions menu for the web part and click "export":


Now save the file to your desktop, and go to the homepage of the site. Switch to "edit page mode", click on "add a web part" in one of the zones, and then on the "advanced web part gallery and options" link at the bottom.
Use the dropdown at the top of the pane to switch to web part import pane:


Now, browse to the saved file and click the "upload" button. The web part should appear as an option in the pane. Drag and drop it to the zone you want it in:




And now you can click on "Exit Edit Mode" and see your wonderful new home page, that is still attached to it's layout page!

The next article will show how to do the same, but with external data!

Monday, April 30, 2007

SharePoint Designer Article 1 - how to edit a page?

In SharePoint 2003 (WSSv2) with FrontPage, it was so easy to edit a page. Just open the page you want to edit in Internet Explorer and hit the "Edit in FrontPage" icon at the toolbar.
Well, the good news are that in SharePoint 2007 (WSSv3) the same applies, but only for some of the pages, while other pages will tell you "This page cannot be edited in SharePoint Designer".

This article will explain what is going on, and how to get each type of page to be editable in SharePoint Designer.

Lets start easy- when you create a WSSv3 web site from one of the default template such as team site, blank site etc...you will have no problems using the easy button - edit in SharePoint Designer:

You can also open the SharePoint site or page for editing from within SharePoint Designer using the "Open Site" or "Open.." dialogs within the application:

When you open such a page from such a site directly from Internet Explorer, or from SharePoint Designer, you will see the page in SharePoint Designer, and be able to modify it using the designer mode or the code mode:

So far so good right?
So lets figure out why some of the pages give us the following message when we try to edit them in SharePoint Designer:
"This page cannot be edited in SharePoint Designer. You can edit the content in the browser, or edit the corresponding page layout in SharePoint Designer"
This page cannot be edited in SharePoint Designer. You can edit the content in the browser, or edit the corresponding page layout in SharePoint Designer

Why is that? well, simply because the page you are trying to edit is under the publishing feature. It is a publishing page, and as such, by default, gets it's layout from the layout page and the master page.
The only change you should be doing on such a page is edit it in the browser and add\remove\change web parts in it.

However, there is a way to work around this - detach it from it's layout page. This is similar to the ghosting\unghosting process that we had back in SharePoint 2003 (WSSv2), but with the added benefit that we can allways roll back the change.
It also means that in the first time you will edit that page, you will have to start from SharePoint Designer to do it:
Open the site that contains the page in SharePoint Designer (use "File>Open Site") and browse to the page you want to edit in the folder list.
Right click the file, and choose "Detach from page layout". This will unghost the file - copying it's layout from the layout page into the database, and so allowing you to edit it, just like you used to do in SharePoint 2003:

Unlike sharepoint 2003, you can take it back, and reattach the file:

Best practice:
Although unghosting is no longer a big bad wolf since it can be undone, you still shouldn't be doing it. It means that the page is disconnected from the layout page that defines the layout for all of the pages in the site. If you will want to make a change to the layout template in the future, this page will not change, unless you reattach the file, but in that case your changes to the file's layout will be lost.
So the best practice from SharePoint 2003 remains - only change a file using SPD if you must. There are ways to avoid editing a file in SPD and still making the changes you thought you had to do using SPD. For example - create a new layout page template, and change the page to use that layout.
Now, I hear you asking - "what about dataviews? we can only add them using SPD!". And I will cover that in my next article on the best practice of how to add a dataview using SPD to a page, without detaching it from its layout page.
If you cannot wait until I find the time for this article, just click on the "frontpage" tag in my blog - and see how I did it with sharepoint 2003 and frontpage. The method is the same.

Thursday, April 26, 2007

Announcing a new series of articles - SharePoint Designer DataViews

I see a growing amount of questions about the SPD dataviews, or questions that can be answered by "use the dataview web part", so I thought I will start a new series of articles of "how-to"s to show how to do common actions using the dataview web part.

I will start by an article on best practices of using the dataview web part - how you should approach using it. Then I will start showing examples of modifying it, using either the built-in menus, or custom xslt samples.
This is actually an upgrade to some articles I have written in the past on how to use the xslt dataview in frontpage, on this blog and in MSD2D.com.

While I am always open to suggestions on what to show, please keep in mind that I will not do your projects for you. My aim is to show how this cool feature can make your life easier, so don't bother posting complex scenarios of things you want to achieve. Simple questions like "can you explain how to use conditional formatting" or "can you give an example on how to transpose a list, so that the rows are columns" will be (probably) accepted.
Also, if you are asking for something, leave your email address (will not be published) so I can notify you when it's published.

So, keep your eyes opened on this blog (you mean you are not registered by RSS? not even by email? well, it's time!)