The SharePoint Happenings Blog has a great post about customizing forms for your lists. I am using this to get rid of certain fields that I do not want to be entered when a new item is added. For instance, I default the Status field to “In Development” (Open/Assigned) and force the user to pick this by hiding the field.
Monthly Archives: July 2008
Theming SharePoint (5 of Infinite)
Today I bring you more of the same! Well, not quite, but today’s post is about navigation. Having covered the left / quick launch navigation, I decided it was time to tackle the top navigation. Reasons? Drop down menus are definately nice, and I think there is a possibility to again get away from tables while adding some nice styling and better functionality. Enter javascript!
Step 1: Get this JavaScript menu (.js) and put it into “C:\…\12\TEMPLATE\LAYOUTS\1033\”
Step 2: Time to get Visual Studio open again, remember that menu we made for the left hand side navigation? Well we can use the same class and reconfigure it a bit for the top nav. This code adds some extra functionality that I will cover in a step or two. Once you are done creating the class, follow the same steps mention in the 4th installment of this series to get the navigation control installed. Continue reading
Theming SharePoint (4 of Infinite)
Michael O’Donovan brings us a blog post about custom (left) navigation in SharePoint. That is what I will be tackling today so I can move away from the ugly Tables and use a more common UL/LI scheme.
Here is my class:
using System;
using System.Collections;
using System.Globalization;
using System.ComponentModel;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.XPath;
using Microsoft.SharePoint.Utilities;
namespace MMOinsite.SharePoint.Components
{
[AspNetHostingPermission(SecurityAction.LinkDemand, Level=AspNetHostingPermissionLevel.Minimal),
AspNetHostingPermission(SecurityAction.InheritanceDemand, Level=AspNetHostingPermissionLevel.Minimal)]
public class ListNavigation : HierarchicalDataBoundControl
{
private XmlDocument navigationTree;
private string currentNodeKey = string.Empty;
private string linkClass = "NavLeftLink";
private string listItemClass = "NavLeftListItem";
private string listClass = "NavLeftList";
private string linkSelectedClass = "NavLeftListItemSelected";
private bool appendLevel = false;
private string appendLevelClass = "NavLeftListItem";
protected override void PerformDataBinding()
{
base.PerformDataBinding();
// Oh god, no data source! ABORT!
if (!IsBoundUsingDataSourceID && (DataSource == null))
return;
HierarchicalDataSourceView view = GetData("");
if (view == null)
throw new InvalidOperationException("Cannot get any data from the data source control.");
IHierarchicalEnumerable enumerable = view.Select();
if (enumerable != null)
{
navigationTree = new XmlDocument();
navigationTree.LoadXml(" ");
try
{
AddNavigationItem(navigationTree.DocumentElement, enumerable, 1);
}
finally { }
ViewState["navXml"] = navigationTree.OuterXml;
}
}
private void AddNavigationItem(XmlElement currentNode, IHierarchicalEnumerable enumerable, int depth)
{
foreach (object item in enumerable)
{
IHierarchyData data = enumerable.GetHierarchyData(item);
NavigationItem navItem = BuildNavigationItem(data, depth);
XmlElement newNavElement = BuildNavigationNode(currentNode, navItem);
currentNode.AppendChild(newNavElement);
if(data.HasChildren)
{
IHierarchicalEnumerable newEnumerable = data.GetChildren();
if(newEnumerable != null)
AddNavigationItem(newNavElement, newEnumerable, depth + 1);
}
}
}
private NavigationItem BuildNavigationItem(IHierarchyData data, int depth)
{
NavigationItem tmpNavItem = new NavigationItem();
try
{
INavigateUIData navNode = (INavigateUIData)data;
tmpNavItem.Title = navNode.Value;
tmpNavItem.Url = navNode.NavigateUrl;
tmpNavItem.Level = depth;
if (currentNodeKey.Length == 0)
{
SiteMapDataSource dataSource = GetDataSource() as SiteMapDataSource;
if (dataSource != null)
if (dataSource.Provider.CurrentNode != null)
currentNodeKey = dataSource.Provider.CurrentNode.Url.ToLower();
}
if (string.Compare(tmpNavItem.Url, currentNodeKey, true, CultureInfo.InvariantCulture) == 0)
tmpNavItem.Selected = true;
}
catch (Exception ex)
{
throw ex;
}
return tmpNavItem;
}
private NavigationItem BuildNavigationItem(XmlNode node)
{
NavigationItem tmpNavItem = new NavigationItem();
tmpNavItem.Title = node.Attributes["title"].InnerText;
tmpNavItem.Url = node.Attributes["url"].InnerText;
tmpNavItem.Selected = Convert.ToBoolean(node.Attributes["isSelected"].InnerText);
tmpNavItem.Level = Convert.ToInt32(node.Attributes["level"].InnerText);
return tmpNavItem;
}
private XmlElement BuildNavigationNode(XmlElement parentNode, NavigationItem navItem)
{
XmlElement tmpNode = navigationTree.CreateElement("node");
tmpNode.SetAttribute("url", navItem.Url);
tmpNode.SetAttribute("title", navItem.Title);
tmpNode.SetAttribute("level", navItem.Level.ToString());
tmpNode.SetAttribute("isSelected", navItem.Selected.ToString());
return tmpNode;
}
protected override void Render(HtmlTextWriter writer)
{
if (navigationTree == null && ViewState["navXml"] != null)
{
navigationTree = new XmlDocument();
navigationTree.LoadXml(ViewState["navXml"].ToString());
}
XmlNodeList nodeList = navigationTree.SelectNodes("nodes/node");
if (nodeList.Count > 0)
{
WriteListStart(writer);
foreach (XmlNode node in nodeList)
{
Render(node, writer);
}
WriteListEnd(writer);
}
}
protected virtual void WriteListStart(HtmlTextWriter writer)
{
writer.Write(string.Format("
- ", ListClass));
}
protected virtual void WriteListEnd(HtmlTextWriter writer)
{
writer.Write("
But how do we install it? Good question John. Why thank you John! Copy it to your server. Open the GAC (C:\WINDOWS\assembly) and drag and drop. Now perform an IISRESET and add the control to your master page in the usual way:
<%@ Register Tagprefix="asp" Namespace="MMOinsite.SharePoint.Components" Assembly="MMOinsite.SharePoint.Components, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abb33cdce6ddaae1" %>
...
It is important to note that the UL/LI scheme is incredibly flexible. You can make them horizontal, drop down menus or keep them as standard vertical lists. Once the control is in place, the designer (CSS for the win here) can take over. For this reason, this type of navigation scheme can also make its way to the top navigation bar. But I will leave that up to you as I have got to get back to work!
Update (9:58): Here are the CSS styles I use with setting AppendLevel to true in the control tag of the master page. There is some pretty wacky CSS going on here and I am sure it can be cleaned up, but it works in IE7 and is a good place to start.
.NavLeftLink{
color: #2D2D2D;
}
.NavLeftListItem{
background: #F2F8FF;
margin-left: 0px;
padding: 0px;
width: 100%;
}
.NavLeftListItem2{
}
.NavLeftListItem a{
padding: 2px 0px 2px 5px;
border-top: solid 1px #25475A;
width: 100%;
}
.NavLeftListItem a:hover{
background: #D4F7B9;
}
.NavLeftListItem1 a{
background: #BACCD6;
font-size: 1.2em;
font-weight: bold;
border-bottom: solid 1px #25475A;
margin-bottom: 1px;
}
.NavLeftListItem2 a{
background: #F2F8FF;
border: 0px;
padding-left: 20px;
font-size: 1em;
font-weight: normal;
background-image: url(/_layouts/images/navBullet.gif);
background-repeat: no-repeat;
background-position: 5px top;
}
.NavLeftListItem2 a:hover{
background-image: url(/_layouts/images/navBullet.gif);
background-repeat: no-repeat;
background-position: 5px top;
}
.NavLeftListItemSelected{
background: #D4F7B9;
}
.NavLeftList{
margin-top: 0px;
margin-left: 0px;
list-style: none;
border-bottom: solid 1px #25475A;
}
.NavLeftList .NavLeftList{
border: 0px;
}
Theming SharePoint (3 of Infinite)
A short one here. When you are going to start theming SharePoint and need to figure out exactly what styles need to be changed, the best tool you can ever get is one like the Web Developer extension for FireFox. Now I hate FireFox, especially 3.x, but I run 2.x at work for the sole purpose of the WebDev extension. Right click on the page, select “Select CSS” under the CSS menu and click away. It will automatically pull CSS styles from the included sheets that pertain to the selected element. This will save hours of time digging through core.css and the page’s source HTML. Trust me.
You may be asking “What else will he post about?” Well, I plan to go through the actual creation of a master page file for the theme from Focused Games but first I have to figure out a few things like how to redo how SharePoint outputs stuff (tables – blegh!). Yeah, I am going that far because I am sick of seeing SharePoint sites that look like SharePoint. In between here and there I will keep touching on the general tidbits of information that may help.
Theming SharePoint (2 of Infinite)
Here is a good blog post about theming the SharePoint top navigation. Today’s post is all about CSS, so pull out your favorite design books… and then light them on fire because they will be of no use here. You’ll want to start off by pulling and probably printing the core.css file that is provided with SharePoint. It may also be a good idea to print the source code of your new non-designed master page. Why? This will give you an idea of what HTML code SharePoint produces and what CSS classes it uses.
Once that is done, go ahead and create a new CSS file in the “Style Library” of your site. Go into site settings for the main site and override the style sheet with that file. This can be found at the bottom. Now you are good to go! Almost… more to come soon.
Here is a little of the CSS you may be employing. This applies to the “Upload Document” style pages and gets rid of the background images and borders:
div.ms-areaseparatorright,div.ms-areaseparatorleft,.ms-nav,td.ms-bodyareapagemargin,td.ms-pagebottommarginleft,
td.ms-pagebottommargin,td.ms-titlearealeft,div.ms-titleareaframe,td.ms-areaseparatorleft,td.ms-titleareaframe,
.ms-titlearearight .ms-areaseparatorright,td.ms-pagebottommarginright,td.ms-sitetitle,td.ms-globalTitleArea
{
border-color: #000;
background: transparent;
}
Theming SharePoint (1 of Infinite)
I am beginning to do themes (master pages) for some SharePoint sites, so here is part 1 of an infinite number of parts (because of how difficult theming SP is) of “Theming SharePoint.”
Assumptions:
- Theming will be done in several ways.
- Any advanced theming will include modifying core template pages.
- The amount of modification is directly related to the number of work arounds needed.
- This is going to suck.
Initial Steps
- Copy default.master from main site catalog directory. Rename and open.
- Erase everything.
- Open default.master in new window.
- Add each individual part, one by one to the page without any layouts.
- I started with the header, copy pretty much everything over.
- Remove all table tags and __designer: attributes.
- Remove all div, p, b, and style tags.
After doing this, you should have a horrible looking page with all the content on it. The important piece here is to get the content working so it is possible to figure out what place holders do what. Next post will be about layouts, the CSS hacks and more.
Update (18:25): Added more detail to the last step. Basically strip everything but the place holders and the controls inside of them.
MGS: Pong (Pages 4-6)
In this fourth [page, second post] installment of the MGS: Pong article series, I am going to cover how to draw a background for the game. Before I start, I should tell you that there will be two more articles: one for creating the menu system and one for pulling all the classes together. Okay, let’s begin! The background class (Background.cs) is incredibly easy to create. First we need some private members to draw the background.
MGS: Pong (Pages 1-3)
In part one of the mini game article series, I am going to show you how to create a very simple Pong game from scratch. The tools you will need include Photoshop (or any other painting program such as Paint.NET or even MSPaint), Visual C# 2005 Express, and of course the Xna framework.
First we need to create our project, to give us a home base for all of our work. Go ahead and fire up C# Express and create an empty windows project. I am going to call mine MGSPong for lack of any imagination or any better title. Once the project has been created, add a folder called “Content” and then another underneath that called “Textures.” This is where we will store out art, no matter how bad it may be!