tag (a row) with some tags inside and a "<?xml:namespace prefix = xsl />xsl:value-of"
Change the text inside to render each image as a link. the following are two examples for how to do that - in one the image is a link to itself, and in the other it is a link to the page the link field we added is pointing at.Code Example 1 - Image is a thumbnail pointing to the bigger image
<xsl:variable select="@ows_link_x0020_to_x0020_open" name="linkText"></xsl:variable>
<xsl:variable select="@ows_RequiredField" name="linkImage"></xsl:variable>
<tr>
<td class="ms-vb">
<a>
<?xml:namespace prefix = xsl />
<xsl:attribute name="href">
<xsl:value-of select="substring-before($linkText,', ')"></xsl:value-of>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="substring-after($linkText,', ')"></xsl:value-of>
</xsl:attribute>
<img border="0" />
<xsl:attribute name="src">http://demo02:8081/<xsl:value-of select="substring(string-length(substring-before($linkImage,substring(normalize-space($linkImage),1,1)))+1)">
</xsl:value-of>
</xsl:attribute>
</img>
</a>
</td>
</tr>
Code Example 2 - Image is a link to a page specified in the custom field
<tr style="display:{$GroupStyle}">
<td class="ms-vb">
<a>
<xsl:variable name="linkText" select="@ows_link_x0020_to_x0020_open"/>
<xsl:variable name="linkImage" select="@ows_RequiredField"/>
<xsl:attribute name="href">
<xsl:value-of xmlns:xsl="http://www.w3.org/1999/XSL/Transform" select="substring-before($linkText,', ')"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of xmlns:xsl="http://www.w3.org/1999/XSL/Transform" select="substring-after($linkText,', ')"/>
</xsl:attribute>
<img border="0">
<xsl:attribute name="src">http://demo02:8081/<xsl:value-of xmlns:xsl="http://www.w3.org/1999/XSL/Transform" select="substring(
$linkImage,
string-length(substring-before($linkImage,substring(normalize-space($linkImage),1,1)))+1)"/>
</xsl:attribute>
</img>
</a>
</td>
</tr>
Liked the tip?
Just had a problem in a customer site, where the search index for non_portal_content was always on 3 documents, even though the customer had about 17 site collections, all with documents and lists with items.
No matter how many times I reset the index, or tried setting up new ones, nothing was added to the index!
If this happens to you, I recommend the following troubleshooting stages:
- Check that the sites are crawled.
In "Site Settings" > "Manage crawls of Site Directory" make sure the sites you want are approved.
didnt help me - they were all approved.
- Make sure you are running SPS SP2.
Some search issues are resolved after installing SP2. To determine you are running SP2, go to the "control panel" > "add\remove programs" and check the "about" of SPS. the version should be 11.0.8126.0 (for the english version anyway).
this improved matters for me - the portal index suddenly worked better, but still empty non_portal_contents
- Do a "Hard Reset" of the index
Ok - last resort:
3.1. First stop the "Microsoft SharePointPS Search" service.
3.2. Now, go to where you installed sharepoint (or if you set the indexes to be in a different location) for example - "C:\Program Files\SharePoint Portal Server\DATA\01b905a4-6f4b-4f3b-bab9-0702d5d86968" and you should see there the "Non_Portal_Content" folder.
3.3. Rename the "Non_Portal_Content" folder to "Non_Portal_Content_Old".
3.4. Start the "Microsoft SharePointPS Search" service again.
3.5 Go to the search administration screen and make sure the index is starting a crawl
Thats it! the last thing solved my problem. the "stuck" index was fully crawled and search works as expected. Hopes this helps anyone...if not - dont blame me!
Hey, I just have to let everyone know about this one.
You know how google (and other search engines) highlights the words you searched for in the results? well, now you can do that in sharepoint!
I wrote this application for Kwizcom (friends of mine). Its a sharepoint portal server search that highlights the searched words in the search page and inside the documents (doc, rtf and pdf). You also can configure how the highlighting will appear (bold? blue? blinking? just configure your own!) and how it will work (case sensative? search whole word or part of a word?).
Oh yeah... a bonus feature (one that customers always ask me for) is that when you click a word document from the search results - it will open up in word and not in the internet explorer window (which is annoying!). Now your users dont have to click "back" to get from the word document back to the search results.
I find it fantastic value... check it out!

WSS site definitions dont support setting a default theme. This leave the administrator with three options, none of them recommended:
- Have users manually set a theme after creating a site (ugly!)
- Set the company theme to a site, and save it as template and deploy the template globaly in the server (complicated, and also disconnects the sites from the file system templates, making it hard to change in the future)
- Change the default css files and not use the theme (extremely ugly - why are the themes for??? also does not support multiple templates with different themes)
The solution I found for the problem (thanks to Kalmberg) is to add in the site definition a link to a custom page that will run code when the site is created. the code will apply the theme to the new site. Kalmberg example was instructive, but allow me to take you through the proccess step by step: Step 1 - Changing The Site Definition - Create the site definition that you want
- Go into the "xml" folder and open the "onet.xml" file in notepad or visual studio (or any editor)
- Find the "Configurations" tag at the bottom, and for every configuration you want to change add the following in the "Configuration" tag (where it says "THEMENAMEHERE" write your theme name. This may be case sensative):
<ExecuteUrl Url="_layouts/1033/ThemeSetter.aspx?Theme=THEMENAMEHERE" />
Step 2 - Creating the ThemeSetter ASPX Page - Open "C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\LAYOUTS\1033"
- Create a new text file, rename it to "ThemeSetter.aspx"
- Open the file for editing, and paste the following code into it:
<html dir="ltr">
<%@ Page Language="C#" ValidateRequest="False" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%
SPWeb myNewWeb = SPControl.GetContextWeb(Context);
myNewWeb.AllowUnsafeUpdates = true;
myNewWeb.ApplyTheme(this.Page.Request["Theme"].ToString());
myNewWeb.Update();
Response.Redirect(myNewWeb.Url);
%>
</html>
Step 3 - Reset the IIS for the changes to take affect, you will need to reset the IIS. Now, create a site from the site definition, and the site should automatically be with the theme.
Liked it?
When creating a dataview for a list using the getlistitems function of the “lists” web service you can display a list from a remote site in your site, without having to develop a custom web part.
However, inserting a link list from a web service shows the links in full text - for example :
"www.msd2d.com, msd2d"
This is because sharepoint stores the link's title and link in a single field with a comma and a space seperating the title and the link.
What you need to do to solve this, is change the xsl of the dataview so that the link will only show the title, while the link will include only the link.
In frontpage, click the dataview and switch to code view. The selected area is the entire dataview defenition. You will need to scroll down and locate the tag definition inside (location may change depending on your list and view).
Change the tag using xsl “substring-before” and “substring-after” functions:
Add an xsl variable that will hold the full link text :
Change the xml of the href attribute to insert the text before the comma:
Change the xml of the text to insert the text after the comma and the text:
This can be confusing, so use my sample code below - just copy and paste it over the existing tag.
You should note that the link field may be named differrently in your list. in a default links list it is named “ows_URL” but in your list you may need to check what the name is. just look in the dataview code before pasting over it.
Code Sample:
<a>
<xsl:variable name="linktext" select="@ows_URL"/>
<xsl:attribute name="href">
<xsl:value-of select="substring-before($linktext,', ')"/>
</xsl:attribute>
<xsl:value-of select="substring-after($linktext,', ')"/>
</a>
This is an answer I gave in MSD2D forum for a question that is frequently asked. Original question is preety confused, but here it is:
"I'm a Sharepoint newbie and am having some problems understanding the relationship between WSS and SPS. We have created a Sharepoint Portal which provides a tab for sites. I also have been able to create Sharepoint sites directly from within the SPS. However, I would like to add some site templates other than the ones shown. When I am in WSS mode, I am given the ability to Manage Site Templates. I can't find the equivalent within the SPS environment. I was given a suggestion to use stsadm.exe for this, but it strikes me as odd to have to use a command-line utility for what I would expect to be a built-in option like WSS provides."
And here is my answer:
The advice you were given was accurate up to a point. there are actually two ways to do what you want, and I prefer the second way. Let me explain:
Quick overeview:
WSS is built in the form of a "Site collection" that hold "webs". what you see as a site is actually a "web" inside the "site collection". The root site is the top level "web" in the site collection. It may or may not have sub webs under it.
This is true when the wss sites are under a portal. every site you create from the portal is actually a different "site collection" with a root "web".
The portal itself is a site collection on its own, with the "home" area as its root level "web". The fact that you create sites from the portal doesnt mean they are actually under the portal. they are infact stand alone site collections with root webs.
WSS site collections have a template gallery you can upload templates to and then use those templates in all webs under the site collection, but you cant use them in other site collections on the same machine unless you install the template globally.
How to install templates globaly
If you have a template you want to be available globaly there are two ways to achive your goal:
Save the web you want using the method you described ("save as template" in the site settings) and then download the stp file to the hard drive and install it with the stsadm command line utility (stsadm -o addtemplate)
Create the new template as a site definition.
Option number two is harder, since you dont get to just create a site, change it to look like you want and just save it. Instead, you have to manipulate aspx and xml files on the hard drive, and define everything manually.
The benefit of the second option over the first is that the sites you will create from the new definition will stay connected to that definition. This means you will be able to change all sites at once if you want to change something in the way they look (not add or remove web parts, but change the layout of the home page). It is also easier to change the template itself when needed.
I suggest you read about it in the link above, and ask here if more info is required.
Post update: my good friends in KWizCom have developed a menu editor for sharepoint. This makes implementing and deploying this article a piece of cake!
Description:
In his article Extending SharePoint 2003 Context Menus, Mark Bower explains how to add a “send link by email” menu item to SharePoint document libraries drop down menus. However, Bower uses a regular mailto link as the mechanism to create the mail item. This method has the advantage that it will work on most browsers and mail applications without any special configurations, but also the disadvantage that if the link has a space in it (for example http://server/document%20library/file%20name.doc) the link will be broken in the email (http://server/document library/file name.doc) which is not a good behavior.
An alternative approach is to use outlook activeX control to create the message and the link, thereby preserving the full link. The disadvantage of this method is that it requires Microsoft Outlook (any version, but not outlook express) and that it requires that the browser allows running activeX controls on the site (register the site as a safe site on the clients).
Although it has drawbacks, it is my belief that most SharePoint users have outlook, and it is a recommended best practice to register the company internal portal as safe anyway. With this in mind, attached is my recommended version of code to accomplish the task.
Sample Code:
*Before changing the ows.js file, please back it up.
The following code is to be inserted into the ows.js file of the SharePoint machine (either WSS only or SPS machine). This causes all document libraries to have the new menu item.
The code sample needs to be inserted into the AddDocLibMenuItems function. The exact location can change – depending on where you want the menu item to be. It should be after the line that starts with “var currentItemEscapedFileUrl”.
//Add the "send mail" link
strDisplayText = "Send Link By Email";
strImagePath = "";
// parse the URL out of the itemTable
var URL = "";
var index = itemTable.innerHTML.indexOf("href=");
if (index > 0)
{
var str = itemTable.innerHTML.substr(index + 6);
index = str.indexOf('"');
if (index > 0)
{
URL = str.substr(0, index);
URL = URL.replace(" "," ");
}
}
if (URL != "")
{
//The following is the original action – using the “mailto”
//strAction = 'window.navigate("mailto:%20?subject=Take a look at this document...&body=' + URL + '")';
//Add the action to open outlook and a new message with a set subject and a link to the document
strAction = "try{var olApp;olApp = new ActiveXObject('outlook.application');var oItem = olApp.CreateItem(0);oItem.Subject = 'Take a look at this document';oItem.HTMLBody = ' " + URL + "';oItem.display(true);}catch(e){alert('Couldnt use the outlook object. Please make sure the current sharepoint site is trusted by your browser and activeX are allowed to run');}";
// Add menu item
CAMOpt(m, strDisplayText, strAction, strImagePath);
// add a separator to the menu
CAMSep(m);
}
Sample Code 2:
*Before changing the ows.js file, please back it up.
If you are unsure how and where to insert the code above, just copy the code below to replace the AddDocLibMenuItems function in your ows.js file. This will be simpler if you are unsure what to do.
function AddDocLibMenuItems(m, ctx)
{
if (typeof(Custom_AddDocLibMenuItems) != "undefined")
{
if (Custom_AddDocLibMenuItems(m, ctx))
return;
}
var RootFolder = GetRootFolder(ctx);
setupMenuContext(ctx);
if (currentItemFileUrl == null)
currentItemFileUrl = itemTable.ServerUrl;
if (currentItemFSObjType == null)
currentItemFSObjType = itemTable.FSObjType;
var currentItemEscapedFileUrl = escapeProperly(
unescapeProperly(currentItemFileUrl));
strDisplayText = "Send Link By Email";
strImagePath = "";
// parse the URL out of the itemTable
var URL = "";
var index = itemTable.innerHTML.indexOf("href=");
if (index > 0)
{
var str = itemTable.innerHTML.substr(index + 6);
index = str.indexOf('"');
if (index > 0)
{
URL = str.substr(0, index);
URL = URL.replace(" "," ");
}
}
if (URL != "")
{
////strAction = 'window.navigate("mailto:%20?subject=Take a look at this document...&body=' + URL + '")';
strAction = "try{var olApp;olApp = new ActiveXObject('outlook.application');var oItem = olApp.CreateItem(0);oItem.Subject = 'Take a look at this document';oItem.HTMLBody = ' " + URL + "';oItem.display(true);}catch(e){alert('Couldnt use the outlook object. Please make sure the current sharepoint site is trusted by your browser and activeX are allowed to run');}";
// Add menu item
CAMOpt(m, strDisplayText, strAction, strImagePath);
// add a separator to the menu
CAMSep(m);
}
if (currentItemFSObjType != 1)
{
strDisplayText = L_ViewProperties_Text;
strAction = "STSNavigate('" + ctx.displayFormUrl+"?ID="+ currentItemID +
"&Source=" + GetSource() + RootFolder + "')";
strImagePath = "";
CAMOpt(m, strDisplayText, strAction, strImagePath);
}
strDisplayText = L_EditProperties_Text;
strAction = "STSNavigate('" + ctx.editFormUrl+"?ID="+ currentItemID +
"&Source=" + GetSource() + RootFolder + "')";
strImagePath = ctx.imagesPath + "edititem.gif";
CAMOpt(m, strDisplayText, strAction, strImagePath);
if (currentItemFSObjType != 1)
{
if (ctx.isWebEditorPreview == 0)
{
if (ctx.listTemplate == LISTTEMPLATE_IMAGE_LIBRARY && itemTable.IsImage == "1")
{
strDisplayText = L_EditInOIS_Text;
strAction = "EditSingleImage('" + currentItemID + "')";
strImagePath = ctx.imagesPath + "oisweb.gif";
CAMOpt(m, strDisplayText, strAction, strImagePath);
}
else
{
setDocType();
if (currentItemAppName != "" && currentItemOpenControl != "")
{
strDisplayText = StBuildParam(L_EditIn_Text, currentItemAppName);
strAction = "editDocumentWithProgID2('" + currentItemFileUrl + "', '" + currentItemProgId + "', '" + currentItemOpenControl + "')";
strImagePath = ctx.imagesPath + currentItemIcon;
CAMOpt(m, strDisplayText, strAction, strImagePath);
}
}
}
}
strDisplayText = L_DeleteDocItem_Text;
strAction = "DeleteDocLibItem('" +
ctx.HttpPath + "&Cmd=Delete&List=" + ctx.listName +
"&ID=" + currentItemID + "&owsfileref=" +
currentItemEscapedFileUrl + "&NextUsing=" + GetSource() + "')";
strImagePath = ctx.imagesPath + "delitem.gif";
CAMOpt(m, strDisplayText, strAction, strImagePath);
if (ctx.isModerated == true)
{
strDisplayText = L_ModerateItem_Text;
strAction = "STSNavigate('" + ctx.editFormUrl+"?ID="+ currentItemID + "&ChangeApproval=TRUE&Source=" +
GetSource() + RootFolder + "')";
strImagePath = "";
CAMOpt(m, strDisplayText, strAction, strImagePath);
}
if (currentItemFSObjType != 1 && ctx.listTemplate == LISTTEMPLATE_IMAGE_LIBRARY)
{
strAction = "DownloadOriginalImage(" + currentItemID + ")";
strImagePath = ctx.imagesPath + "download.gif";
strDisplayText = L_DownloadOriginal_Text;
CAMOpt(m, strDisplayText, strAction, strImagePath);
}
if (currentItemFSObjType != 1)
{
CAMSep(m);
AddCheckinCheckoutMenuItem(m, ctx, currentItemEscapedFileUrl);
AddVersionsMenuItem(m, ctx, currentItemEscapedFileUrl);
CAMSep(m);
if (ctx.PortalUrl != null)
{
strDisplayText = L_AddToMyLinks_Text;
strAction = "Portal_Tasks('PinToMyPage')"; ;
strImagePath = "";
CAMOpt(m, strDisplayText, strAction, strImagePath);
strDisplayText = L_AddToCategory_Text;
strAction = "Portal_Tasks('Categorize')"; ;
strImagePath = "";
CAMOpt(m, strDisplayText, strAction, strImagePath);
CAMSep(m);
}
}
strDisplayText = L_Subscribe_Text;
strAction = "NavigateToSubNewAspx('" + ctx.HttpRoot + "', 'List=" + ctx.listName + "&ID=" + currentItemID + "')";
strImagePath = "";
CAMOpt(m, strDisplayText, strAction, strImagePath);
if (currentItemFSObjType != 1)
{
strDisplayText = L_Discuss_Text;
strAction = "STSNavigate('" + ctx.HttpPath + "&Cmd=COMMFRMS&URL=";
if (ctx.isWebEditorPreview == 0)
strAction += currentItemEscapedFileUrl;
strAction += "')";
strImagePath = ctx.imagesPath + "icdisc.gif";
CAMOpt(m, strDisplayText, strAction, strImagePath);
if (ctx.listTemplate != LISTTEMPLATE_IMAGE_LIBRARY)
AddWorkspaceMenuItem(m, ctx);
}
// add a separator to the menu
CAMSep(m);
}
Acknowledgments:My thanks to Mark Bower and\or to Alan Smithee who published the original document in Microsoft’s site.
|