P:<xsl:value-of select="name()" />
The CQWP will now list out all of the fields that are being passed.
Add this snippet of code to the Item Style (Style Sheet) file to render the names of the fields being passed to the Content Query Web Part (CQWP). Note that this code will be temporary. You don't want to leave this in the finished Item Style!
<xsl:template name="RenderFieldsBeingPassed" match="Row['RenderFieldsBeingPassed']" mode="itemstyle">
P:<xsl:value-of select="name()" />
Save the file. Return to the site (in the browser) and refresh the page. Open the Web Part Tool Pane for the CQWP and expand Presentation. Then under Styles change the Item Style to the new custom style (RenderFieldsBeingPassed) in the drop down. Select Apply.
The CQWP will now list out all of the fields that are being passed.
Some of the changes that Microsoft has made to SharePoint has made Designers' work a little bit more cumbersome. One of the things that I remember being able to do in MOSS 2007 was the ability to create publishing sub site templates that I could reuse over and over again.
They say that Microsoft never intended for us to be able to create publishing sub site templates, not even in MOSS 2007. But by turning the publishing feature off, we were able to get around and save the sub site as a template, create a new one from said template, and then turn the publishing features back on for the newly created sub site.
(Another trick was to backup the sub site in SharePoint Designer and then restore it over a blank sub site. But that option is gone in SharePoint 2010, as well.)
So the only way I found to make my life a bit easier as as Designer and to reduce the amount of repetitive work is using the Manage Content and Structure tool.
1. Create the publishing sub site you want to use as template for creating the new ones
2. Create all pages and components (lists, web parts, etc.)
3. Once you have completely created your publishing sub site, the one that is going to serve as template, go to the level right above it and select [Site Actions] > Manage Content and Structure
4. Click the row where the name of the sub site displays and select Copy from the pop-up menu
5. Select the destination where you would like to paste the sub site to
6. Access the newly created sub site via your browser (you will need to leave the Site Content and Structure page), rename the sub site, edit the home page, edit any content query web parts (if any) that you may have on the home page or any other pages to the case, and make them point to the sub site’s lists and libraries, instead
Important Note: When a sub site is created this way, web parts such as the Content Query Web Parts will still be pointing to the original sub site used as template for creating new sub site.
That’s it. The only thing to keep in mind is that when you modify the path to the appropriate list or library for a content query web parts by using the [Browse] button you will lose all the other settings for said Content Query Web Part (for example, filters, etc.). To prevent this from happening, edit the path manually (for example, if the path to is /SiteName/SubSiteTemplates/SubSiteTemplateName/Lists/ListName and it should read /SiteName/NewSubSiteName/SubSiteTemplateName/Lists/ListName, type in that one section of the path; this will prevent the filters from being cleared.)
The steps below allow you to add a "Welcome to the site, Jane Doe!" welcome message to a page. We did this to insert it to an Announcement list.
1. Using SharePoint Designer, insert a Data View Web Part based on the Announcement list;
2. Select Data > Conditional Formatting;
3. Select any data value and select Create;
4. Select Show Content;
5. Create a condition that reads Title EQUALS [Current User] and select [OK];
6. Go back to the Design view;
7. Type "Welcome to the site, " inside one of the Table cells;
8. Switch to Code view;
9. Find the following code:
<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
10. Change this code to:
<ParameterBinding Name="UserID" Location="CAMLVariable;ServerVariable(LOGON_USER)" DefaultValue="CurrentUserName"/>
11. Scroll up in the code and find "Welcome to the site, "
12. Change this code to: "Welcome to the site, <xsl:value-of select="$UserID"/>"
13. Save the page.
As part of one of my assignments I needed to insert four Content Query Web Parts at the bottom of my custom master page for the site. This was a somewhat easy thing to do in MOSS 2007 and you would do it only once on the master page itself. Well, that’s not the case in SharePoint 2010 anymore. You cannot insert Web Parts on a SharePoint 2010 Master Page at all. However, I found a way around it.
Microsoft might have taken that functionality away from us in what concerns Master Pages. But… they have not taken it away when it comes to page layouts. You can insert web parts in a custom page layout.
The main con about this approach is that if you need those web parts available to all pages being created on your site, then you have to create a copy of each page layout available out there and insert the web parts to all of them. So when your customers create new pages, the web parts are going to be there. (By inserting them once in the MOSS 2007 master page you were done; now you have to replicate the job for all page layouts for which you want those web parts to display.)
Note: As I always emphasize, make sure you are working on a copy of Microsoft’s originals and leave the originals from Microsoft alone.
This is what you need to do:
1. Create some “test” or “hidden” page somewhere on the site where you can create your web parts and edit the page;
2. Insert the web part at any web part zone on the page (it doesn’t really matter where since this is more of a placeholder until you are done creating the web part completely). In the case of custom Content Query Web Parts, do all of the necessary customizations to the web parts, style sheets, CSS rule sets, etc.
3. Download the web part or web parts to your hard drive;
4. Upload the web part or web parts to the site’s Web Part Gallery;
5. Using SharePoint Designer, open your custom page layout
6. Go to the location of the page where you would like to insert the web part (it could be a row or cell in a table or a <div>); I usually work in split mode. You may want to use the Code or Design view; it’s up to you and whatever it is easier for you.
7. Select the Insert tab on the ribbon and then select Web Part within the Web Parts group;
8. SharePoint Designer will display a Web Part drop-down menu; locate the web part uploaded in step 4 above and insert it in your page;
9. Save, check in, and publish the page;
10. Go back to your site using Internet Explorer this time (not Designer) and create a page using the modified page layout. Or if you have already created a page using this particular page layout, open it. Make sure the web part is now displaying at the desired location on the page.
When displaying dates using Data View or Content Query Web Parts, you might need to format them to the local standards. In order to do that, you may need to use date format functions. But before you can use those, you may need to add a Microsoft schema that does not come by default on your XSL Style Sheet.
I always recommend creating copies of the original files from Microsoft. So I'm assuming that you have created a copy of the original XSL style sheet and you are going to be working on this copy.
Open your XSL Style Sheet. Before modifications, your style sheet should read as follows:
exclude-result-prefixes="x d xsl msxsl cmswrt"
After modifications it should read as this:
exclude-result-prefixes="x d xsl msxsl cmswrt"
Then insert the format date function in the appropriate line of your style sheet. For example, for today's date:
If you would like to have the date in YYYYMMDD format, you can convert it using the FormatDateTime ddwrt function; for example:
<xsl:value-of select="ddwrt:FormatDate(string(ddwrt:Today()), 1033, 'yyyyMMdd')"/>
Click here to view a full list of Locale IDs (LCID) that can be used as an aid in setting different formats based on locale.
When we migrated from MOSS 2007 to SharePoint 2010, we encountered a little bump on the road: SharePoint 2010 was forcing PDF files stored in a document library to be downloaded before opening them instead of directly displaying them in the browser.
Microsoft incorporated a feature within Central Administration for SharePoint 2010 to prevent files to be opeed within the browser.
Engineering helped to solve it. But once in a while a site would still behave differently than what we wanted it to. So this is what I did in those situations.
First I would make sure that my Adobe was set up for opening the files in the browser. To check this, I would open any PDF file and then I would select Preferences at the Edit menu. Then I would select Display PDF in browser (under Web Browser Options).
Back in my SharePoint site I would try again. If the step above would not solve it, then I would contact someone in Engineering to fix it for me since I didn't have access to Central Administration and that's where the setting I needed changed was.
In case you are curious as of what actually this setting is, I'm talking about the Browser File Handling setting within Manage Web Application within Central Admin, which in our case was set to ‘Strict,’ preventing the files from being opened in the browser. In order for PDF files to be opened in a browser window, that setting should be set to ‘Permissive.’
Another advantage of the solution presented on this post is that with other solutions you need 2-3 images per menu option: One for when the page is not active, one for when the user points at the menu option (hovers), and one for when the page is active. With the solution presented in this page, you will only need one image per menu option.
Finally, the last advantage is no flickering when hovering over the menu options. With other solutions where more than one image is used for each menu option status is a flickering effect when the browser tries to upload the image for each particular status. This flickering is more notorious if the network performance degrades for whatever reason. You can avoid this effect by implementing the present solution.
What you need:
- Stacked images (one for each menu option)
- HTML code for links
- CSS code
Step 1: Create a "Stacked" Image
The first thing you need to do is create what's referred as a "stacked" image using a graphics tool such as PhotoShop, Fireworks, etc. A stacked image is an image that contains all states (inactive and hover) in one single image stacked one on top of the other. (See image to the left for an example.)
You will need to create one of these images per as many menu options as you may have. Once you have created your images, upload them to the appropriate SharePoint image library.
Take note of the actual size of your image (on a related note, all images should be the same exact size to work smoothly). You will need this information in the third step, where you will set the appropriate values on the CSS code. In our example, the image size is 210 x 106 pixels.
Step 2: Create the Markup on the Master Page
The HTML code needed is just a link with an id and a span element wrapped around the link text. You will need to insert it on your customized master page and where you want the left navigator to display.
<a id="homeMenu" href="<insert link here>" title="Home"><span>Home</span>
The ID given to the link in the example is "homeMenu." This allows you to style the link via your CSS. Then, the actual link text is placed inside a span element, which means that you can hide the link text with your CSS and display the image instead, yet the link still looks like a regular text link to browsers not using the style sheet (such as, for example, a search engine spider or text-only browser).
You will need to insert this markup text for each of your menu options and changing the ID, HREF, and Title values for each option as appropriate.
Step 3: The CSS
Finally, to turn the regular text link into a rollover button, you need to modify your CSS style sheet by applying the CSS below.
background: url('<insert_link_to_image_here>) no-repeat 0 0;
background-position: 0 -106px;
The display: block line allows you to give the link a width and height, as well as set your button image as a background. The next two lines set the width of the link element to the width of your image, but it also sets its height to half the height of the image (that would be the height of one of the button images in the stacked image). This means that just the top, normal button image will appear within the link by default. The bottom, which is the rollover image, is cut off, therefore remaining hidden.
The next line (background-position: 0 -106px;) selects the link's :hover pseudo-class to style the rollover state. What happens is that the background image shifts up, in this case by 106 pixels, which is half the image's height. This hides the normal button image above the top of the link element, revealing the rollover button image within the link. (Another way of thinking about it is as sliding the image upwards within the "window" of the link.) When the visitor moves their mouse away from the link again, the button slides back down 106 pixels, returning to its default position, and revealing the normal button image within the link.
The last line, display: none, hides the link text for browsers that support CSS and images.
(Optional) Step 4: Creating More Than One Button
If you want or need to create more than one rollover buttons, copy and paste the HTML and CSS as many times as needed. Just remember to give each button a unique ID in both the HTML and the CSS, as well as changing the background image for each button in the CSS.
Another alternative would be to style the link text to be in the center of the button image, rather than being hidden. In this case, you would only need one (blank) button image for all the menu options. The only con this approach has is that you lose some control over the look of your button text and the buttons may not look as nice.
Don't forget to modify the master page to point to the customized CSS.
We have used the formula below to concatenate information such as document name and version, or to create unique IDs in SharePoint.
1. Create a Calculated value column
2. Use the formula below,
Note: Replace the generic ColumnName1 and ColumnName2 in the example above with the name of your respective columns.
Once in a while we get a customer who wants us to remove the checkboxes that display at the top on a list view web part.
This can be accomplished within SharePoint 2010 itself and by modifying the applicable list view.
Modify the list and locate the Tabular View section near the bottom. Expand this section and clear the Allow individual item checkboxes option.
Note: After modifying the view, you may need to reapply the view at the web part level on the page where it displays. Sometimes this type of changes are not immediately reflected on the pages, if never. So you have to force the change to go through, in which case you need to edit the page, edit the web part, and select the view at the Select View drop-down list within the List View section of the web part editing tool pane.
Use this solution if you are requested to completely hide the View All Site Content menu option from the [Site Actions] menu of a site.
1. Using SharePoint Designer edit your custom copy of the v4.master master page
2. Using SharePoint Designer's Code view, locate the section with an
3. Once you located this section, locate the PermissionsString and change the default value of "ViewFormPages" to "ManageWeb."
4. Save, check in, and publish your custom master page
5. Open the site in the browser and test it with a few users who have been granted different access level. With this new setting, the View All Site Content option will display only for those users who have access to higher features within the site.
Click here for more settings for the Permissions String.