I was asked today about hiding the Recenlty Modified menu from the quicklaunch of SharePoint 2010 Team Sites.
dinsdag 18 december 2012
SharePoint 2010: Expand the User Profile info by default
Out of the box, the SharePoint 2010 User Profile page uses a bit of JavaScript to truncate the user’s info like Email, School etc. with a “more information” hyperlink that can be clicked to show all the info. The user’s description text is also similarly semi-hidden on page load.
The following quick CSS hack can make both these detail areas fully visible by default, and also hide the “more information” / “hide information” hyperlink”:
SharePoint 2010: minimal.master
List of all the required ContentPlaceHolders:
woensdag 5 december 2012
SharePoint list view group by content type
SharePoint 2010 ViewEdit Group By Content Type
Actually it’s nothing more than adding some javascript with a script link to each page.
vrijdag 16 november 2012
Images from picture library not displayed in IE
Today I discovered a strange behavior in Internet Explorer. I uploaded some images to my image library and I referred to them in my custom aspx page. All the images displayed correctly except one. In Firefox everything rendered correctly, in IE only the thumbnail and the web image was available. The full image was not available and I received a red cross on my page.
Conclusion: the image was corrupt!
donderdag 15 november 2012
How to use SharePoint’s default modal popup from code behind?
A while ago I needed to create a shopping basket. When you click on an item in that basket it would be nice if that item opens in a modal popup. But how can you access the default SharePoint modal popup dialog if it isn’t in your masterpage?
I used following code:
public static class Helper{public static string GetDialogURL(string url, bool refreshOnClose, double width, double height){string str = string.Concat(new object[]{"SP.UI.ModalDialog.showModalDialog({ url:'",url,"',tite: 'Move Documents',allowMaximize: true ,showClose: true,width:",width,",height:",height});if (refreshOnClose){str += ",dialogReturnValueCallback: function(dialogResult){SP.UI.ModalDialog.RefreshPage(dialogResult)}";}str += "});";return str;}public static string GetDialogURL(string url){return Helper.GetDialogURL(url, true, 700.0, 800.0);}}
maandag 12 november 2012
XSL template to obtain all visible fields in Content Query WebPart
<xsl:template name="ShowXML" match="Row[@Style='ShowXML']" mode="itemstyle"><xsl:variable name="SafeLinkUrl"><xsl:call-template name="OuterTemplate.GetSafeLink"><xsl:with-param name="UrlColumnName" select="'LinkUrl'"/></xsl:call-template></xsl:variable><xsl:variable name="DisplayTitle"><xsl:call-template name="OuterTemplate.GetTitle"><xsl:with-param name="Title" select="@Title"/><xsl:with-param name="UrlColumnName" select="'LinkUrl'"/></xsl:call-template></xsl:variable><b>Item: <i><a href="{$SafeLinkUrl}" title="{@LinkToolTip}"><xsl:value-of select="$DisplayTitle"/></a></i>:</b><ol><xsl:for-each select="@*"><xsl:sort select="name()"/><li><xsl:value-of select="name()" /><xsl:text disable-output-escaping="yes"> </xsl:text><i><xsl:value-of select="."/></i></li></xsl:for-each></ol><br /></xsl:template>
Notice that @ is the beginning char of any list field.
woensdag 7 november 2012
SharePoint 2010 Search Center MasterPage with navigation
Minimal masterpage with navigation
woensdag 31 oktober 2012
SharePoint 2010 Branding: what’s publishing masterpage all about
v4.master
Enjoy it!
Transparency settings for all browsers
Transparency css that covers all browsers.
Very handy css class
.transparent
{
/* Required for IE 5, 6, 7 */ /* ...or something to trigger hasLayout, like zoom: 1; */}
width: 100%;
/* Theoretically for IE 8 & 9 (more valid) */ /* ...but not required as filter works too */ /* should come BEFORE filter */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
/* This works in IE 8 & 9 too */ /* ... but also 5, 6, 7 */
filter: alpha(opacity=50);
/* Older than Firefox 0.9 */
-moz-opacity:0.5; /* Safari 1.x (pre WebKit!) */
-khtml-opacity: 0.5;
/* Modern! /* Firefox 0.9+, Safari 2, Chrome any? /* Opera 9+, IE 9+ */
opacity: 0.5;
donderdag 25 oktober 2012
Set ribbon smaller via CSS
Thanks to my colleague (Laurent Schoenaers) for following css:
body #s4-ribbonrow {background-color: #FFA113; margin-top: -20px;}.ms-siteactionsmenuinner {background:transparent;background-color:#FFA113;border-color:#FFA113;}.ms-cui-topBar2 {border-bottom:0px;}.ms-cui-TabRowRight {margin-top: -12px !important; padding-top: 36px !important;}.ms-cui-ribbonTopBars div {border-bottom:1px solid transparent;}.s4-trc-container-menu {margin:0;}
before:
after:
woensdag 24 oktober 2012
SharePoint 2010 template for Photoshop
You can download below the default SharePoint 2010 team site design in photoshop format. Every part is created in a layer.
SharePoint 2010 design assets
RichHtmlField for custom field not rendering HTML
RichText="True"
RichTextMode="FullHtml"
I found a script to update the problem field, and the problem went away for me (look below for script). The change has to be made at the list level for it to take affect on existing pages/lists, but I believe making the modification to the column at the root web (or correct subweb) would work as well.
$web = $site.OpenWeb($site.RootWeb.ID) $list = $web.Lists["Pages"] [Microsoft.SharePoint.Publishing.Fields.HtmlField]$field = [Microsoft.SharePoint.Publishing.Fields.HtmlField]$list.Fields.GetFieldByInternalName("PageContentFld") $field.RichText = $true $field.RichTextMode = [Microsoft.SharePoint.SPRichTextMode]::FullHtml $field.Update() $list.Update()
You may want to check your field to make sure those properties are set.
donderdag 6 september 2012
Trigger resize event with jQuery cross-browser
Bind an event handler to the "resize" JavaScript event, or trigger that event on an element
jQuery has a built-in method for this:
$(window).resize(function () { /* do something */ });
For the sake of UI responsiveness, you might consider using a setTimeout to call your code only after some number of milliseconds, as shown in the following example, inspired by this:
function doSomething() {
alert("I'm done resizing for the moment");
};
var resizeTimer;
$(window).resize(function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(doSomething, 100);
});
vrijdag 24 augustus 2012
SharePoint 2010: custom markup styles
How to complete customize the SharePoint 2010 markup styles
- Font colors
- Fonts
- Font Sizes
- Mark colors
- Predefined Styles
- Predefined Markup Styles
maandag 20 augustus 2012
Calculate total size of SPWeb object
private static long GetWebSize(SPWeb web)
{
totalWebSize += GetFolderSize(folder);
vrijdag 10 augustus 2012
SP2010: Set rigths of custom action
Set the rights of a custom action
<CustomAction
UrlAction Url="~site/_Layouts/CreatePage.aspx"/></
CustomAction>
This property is needed if you want to set minimal rights to execute your custom action.
donderdag 9 augustus 2012
Add jQuery library to a webpart via code
Add the jQuery library reference via code to your webpart.
protected override void Render(HtmlTextWriter writer) {
writer.AddAttribute(HtmlTextWriterAttribute.Src, "/_layouts/1043/STYLES/myUZA/js/jquery-1.4.2.min.js"); writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript"); writer.RenderBeginTag(HtmlTextWriterTag.Script); writer.RenderEndTag();
Another option is to do it in a full javascript block. You write the javascript code, put it in a string and register the javascript block via C# code:
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = '/_layouts/1043/STYLES/myUZA/js/jquery-1.4.2.min.js';
document.getElementsByTagName('head')[0].appendChild(script);
}
</script>";
if (!Page.ClientScript.IsClientScriptBlockRegistered(jsKey))
woensdag 8 augustus 2012
SharePoint 2010: Document Library - Group By expand on item click
Expand group by clicking on the item
vrijdag 6 juli 2012
SP2010 Sequential Workflow Send Email
Send Email in a sequential workflow
SPUtility.SendEmail(workflowProperties.Web, true, false, confirmationMail.To, confirmationMail.Subject, confirmationMail.Body);
SP2010: Sequential Workflow Correlation Token SendEmail
Workflow Foundation Correlation Token error
- WinWF Internal Error, terminating workflow Id#
- System.InvalidOperationException: Correlation value has not been initialized on declaration emailToken_JobNumberCreate for activity sendEmail_JobNumberNotCreated. at System.Workflow.Activities.CorrelationService.InvalidateCorrelationToken
The correct Correlation Token for a SendMail Activity is the “Workflow” token. The reason, which is fairly obvious, is that the SendEmail activity maps to the workflow, not to a task, which would require a Task Token
vrijdag 22 juni 2012
SharePoint 2010: Manage navigation programmatically C#
How to set navigation options programmatically?
- Don't inherit global navigation
- Don't include pages in global navigation
- Include subsites in quicklaunch
- Set ordering
- Set navigation items of the topnavigation manually via xml
- Add parent site to the quicklaunch if it exist
donderdag 14 juni 2012
SharePoint 2010: Create a custom wiki page
How to create a custom wiki page in SharePoint 2010 with a simple FeatureReceiver?
With this code it's pretty easy:
private string wikiFullContent = string.Empty;
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPWeb web = properties.Feature.Parent as SPWeb)
{
//* Define page payout
wikiFullContent = FormatBasicWikiLayout();
//* Add page to library
SPList sitePages = web.Lists.TryGetList("$Resources:core,WikiLibDefaultTitle;");
if (sitePages == null)
{
sitePages = web.Lists.EnsureSitePagesLibrary();
}
woensdag 13 juni 2012
SharePoint 2010: Restrict web templates
Define which web templates may be available when you create a subsite
In the analysis of a new project was described that the users only a few webtemplates could see when they want to create a new subsite. After some research on the internet I found that it is possible to define that via the UI of SharePoint 2010:
Site Actions -> Site Settings -> Page layouts and site templates
(default)
(after the selection)
In this settings page you can define which web templates you set available but that's not a solution on the question of the analysis. You can't ask to each contributor to set this setting by themself so I wrote a featureReceiver and via featureStapling I hang to the defined site templates.
Important! If you want to do this via code be sure that the Publishing Infrastructure and Publshing Feature is activated!
dinsdag 12 juni 2012
SharePoint 2010: Starter v4.master without tables
Starter v4.master with div tags instead of table tags
SharePoint 2010: Show the parent site in the breadcrumb
How to show the parent site in the breadcrumb of your custom masterpage?
The css here defined contains the default style of the v4.master headbreadcrumb.
maandag 11 juni 2012
SharePoint 2010: Custom Site Definition
Failed to instantiate file "default.master" from module "DefaultMasterPage"
<Template Name="CustonSiteDefinitions" ID="10000">
Must match the folder in your SiteTemplates directory:
14/TEMPLATE/SiteTemplates/CustomSiteDefinitions