3/02/2011

SharePoint, JavaScript and Dates

 

How does your SharePoint site display a date?

The answer is… “it depends.”  Create a new task and schedule it for January 3rd, 2012. Now display the task list and see how the date is displayed.

Do you see this image  or this image

You would see the first if you had your SharePoint preferences (Regional Settings) set to a country where they enter dates as dd/mm/yyyy, such as France.

To play with the regional settings, click the Welcome menu at the top right of a SharePoint page and click My Settings. Then click My Regional Settings, uncheckmark “Always follow web settings” and pick a locale.

image  

image

image

 

So what’s the problem?

If you are writing JavaScript code that needs to work with the date you may get the wrong date! As an example, if you wrote some JavaScript to read the Due Date from a task and changed the color or font for past due tasks you would probably use the Date.parse method to test the date:

var colDueDate = 7; // list column with Due Date
if (d.getTime() >= Date.parse(row[i].parentNode.childNodes[colDueDate].childNodes[0].innerHTML) )
{
  row[i].parentNode.style.backgroundColor='red'; // set the color
}

In this example, if today’s date is February 15th 2012 and the Due Date is March 1st 2012 then Date.parse would show the task as past due for the French users and not past due for the United States users.

JavaScript date references:

http://msdn.microsoft.com/en-us/library/ff743760.aspx

http://www.w3schools.com/jsref/jsref_parse.asp

 

The fix?

Display the date in a format that Date.parse likes. JavaScript first attempts to parse the date as an ISO formatted date. It then tries a few other rules, but none of those support dd/mm/yyyy. What we need to do then is deliver a date from SharePoint that will always work with JavaScript, and one that always works is yyyy/mm/dd. You could just pick a locale that uses that format, but your users are not likely to be happy with that.

What works in my projects is to add a calculated column to my list that generates yyyy/mm/dd format, hide that column in the display and use that column for my JavaScript date math.

  1. Add a new column to your list and give it a name like DueDateYYYYMMDD
  2. Add a formula:
             =YEAR([Due Date])&"/"&MONTH([Due Date])&"/"&DAY([Due Date])

    image 
  3. Save your changes
  4. Add this new column to your view
  5. Add some tasks with a due date and verify that both Due Date and DueDateYYYYMMDD have the same dates, just formatted differently
  6. Go to your Welcome menu, click My Settings, My Regional Settings and change your locale to France and confirm that while the Due Date column has changed, the DueDateYYYYMMDD is still the same

Make it do something useful

The JavaScript below is an update to the “SharePoint: Past Due / Late Tasks in a Task List” article. The code now works regardless of the SharePoint or user locale (date format) settings.

image

 

<script type='text/javascript'>
// customization trick from TechTrainingNotes.blogspot.com
 
var colDueDate = 6;  // This is the column with the due date in the YYYY/MM/DD format
var colToHide  = 6;  // This is the same column as above if you want to hide the custom date format
var colPastDue = -1; // optional column to display a custom JavaScript set message
var tableName = "Tasks"; // (from summary="")
 
// find the table for the list
var tables = document.getElementsByTagName("TABLE");
var table
for (x in tables)
{
  if (tables[x].summary == tableName)
  {
     table = tables[x];
     break;
  }
}
 
// hide the column with the special date (optional)
if (colToHide > -1)
{
  var TRs = table.getElementsByTagName("TR");
  for (x in TRs)
  {
 
    var toHide = colToHide;
    if (TRs[x].innerHTML)
    {
      if (TRs[x].innerHTML.toString().toLowerCase().indexOf("iframe") > -1 )
      { toHide += 1; }; // fix for 2007
 
      try {
      } catch (e) {}
      if (TRs[x].childNodes && TRs[x].childNodes.length >= toHide)
      {
        TRs[x].childNodes[toHide].style.display="none";
      }
    }
  }
}
 
// Color code the row based on a date calculation
var TDs = table.getElementsByTagName("TD");
var now = new Date();
for (i in TDs)
{
  if (TDs[i].className=="ms-vb2") //find the TDs styled for lists 
  {
    //find a row with a key phrase
    if (TDs[i].innerHTML=="Not Started"
         | TDs[i].innerHTML=="In Progress"
         | TDs[i].innerHTML=="Waiting on someone else" )   
    {
      // is this row (task) past due?
      if (now.getTime() >= Date.parse(TDs[i].parentNode.childNodes[colDueDate].innerText) )
      {
        // set the color
        TDs[i].parentNode.style.backgroundColor='red'; 
        
        // optionally display a message in another empty column
        if (colPastDue > -1)
          TDs[i].parentNode.childNodes[colPastDue].innerHTML='Past due!'; 
      }
    }
  }   
}
</script>

 

.

3/01/2011

SharePoint Datasheet View vs. 64 bit Office

 

If you try to use the SharePoint Datasheet view and get this error:

The list cannot be displayed in Datasheet view for one or more of the following reasons:

  • A datasheet component compatible with Microsoft SharePoint Foundation is not installed.
  • Your Web browser does not support ActiveX controls.
  • A component is not properly configured for 32-bit or 64-bit support.

then you may have 64 bit Office (or any one 64 bit Office application such as Excel) installed!

 

Or… you may be using the 64 bit version of Internet Explorer!

 

Here is the Microsoft article that recommends not using Office 64 bit for most users:

http://technet.microsoft.com/en-us/library/ee681792.aspx

I’ll summarize… “If you want any Office integration with anything else… don’t install 64 bit Office!

 

If you must use 64 bit Office and still want SharePoint and other things to still work… and you are willing to live with and issue or two…

http://support.microsoft.com/kb/2266203

 

 

For most other datasheet errors just check the online help:

 

Status bar displays 'Read-only' or 'This view is read-only'

The selected cell, column, row, or the entire view is read-only. You cannot edit a cell, column, or row that is marked read-only. If the entire view is read-only, you cannot edit any portion of the view.

Portions of a view, or an entire view, might be read-only due to one or more of the following reasons:

  • Certain columns, such as Created By and Modified, are always read-only. Values for these columns are entered automatically.
     
  • The changes you made to the selected row or column have been submitted to the server. If there is no conflict or error, you will be able to edit the row or column after the changes have been saved.
     
  • There is an unresolved conflict or error in the selected row or column. Resolve the conflict or error before attempting to edit the selected row or column.
     
  • The list is set up to require content approval, and you are viewing the list in the All Items view.
     
  • In the My Submissions view of a list that requires content approval, the Approval Status and Comment column are read-only. Only a user with Manage Lists right can edit these two columns.
     
  • Attachments are read-only in a list that requires content approval. You cannot view or edit attachments in any of the views.
     
  • The document in the current row has been checked out by a user. You cannot edit the columns in the row until the user checks the document in.
     
  • You do not have permission to edit the column or row. Contact the list author for more information.

 

.

2/24/2011

SharePoint: Prevent the Closing of web parts

 

The following works in both SharePoint 2007 and 2010.

 

If you have worked with SharePoint for a while you probably have learned that in most cases Closing a web part is “bad” and Deleting a web part is “good”.  (Do a web search on “SharePoint web part close vs delete”.)

 

So how can you prevent the closing of a web part?

How about five ways…

 

1) Every time you add a web part go to the Advanced section of the properties panel and uncheckmark “Allow Close”  (too much work)

image

 

2) Add a little JavaScript to prevent the Close:

image

 

3) Add a little JavaScript to disable the Close Option

image

 

4) Add a little JavaScript to hide the Close Option (probably the best choice)

image

 

5) Add a CSS style to hide the Close option (easy to do, but it leaves a blank line)

image

 

 

I prefer #4!

 

 

The JavaScript to prevent the close and display a popup:

Add the following to your site’s master page just before the </BODY> tag (A SharePoint Designer task!) or in a Content Editor Web Part (last one on the page) if you just want this for a single page.

<script>
  // JavaScript to block the closing of web parts
  // TechTrainingNotes.blogspot.com

  var oldClose = MSOLayout_RemoveWebPart;
  MSOLayout_RemoveWebPart = function (x)
  {
    alert("Closing of web parts has been disabled");
  }
</script>

 

 

The JavaScript to Disable or Hide the Close option:

Add the following to your site’s master page just before the </BODY> tag (A SharePoint Designer task!) or in a Content Editor Web Part (last one on the page) if you just want this for a single page.

<script>
// hide or disable the web part Close option
// TechTrainingNotes.blogspot.com

_spBodyOnLoadFunctionNames.push('hideWebPartClose');

function hideWebPartClose()
{
  var x = document.getElementById("MSOMenu_Close")

  // uncomment the next line to just disable (gray out)
  // x.disabled=true

  // uncomment the next line to hide the close option
  x.hidden=true

}
</script>

 

The CSS to hide the Close option:

Add this to your master page, your linked style sheet file or to a Content Editor Web Part.

<style>
  #MSOMenu_Close
  {
    display:none
  }
</style>

 

.

2/23/2011

SharePoint Cincy 2011 presenter list has been posted

 

Register now!  There is limited space available at the METS Center.

image

 

Speakers

The speaker list is not complete yet. See here for the current list: http://www.sharepointcincy.com/presenter-information

KEYNOTE SESSIONS:

  • Microsoft Executive, Fred Studer, has P&L responsibility for a $6B portfolio of Information Worker (IW) products.  Come hear Fred discuss the strategic importance and future direction of SharePoint.

  • Kroger IT leader, Catherine Allshouse, will share how they use SharePoint to deliver as many as 2 million customer interactions/day on Kroger’s websites.

 

One SharePoint MCM, at least two SharePoint MVPs and at least one MCT!

And a lot of Microsoft Certified “fill in the blank”  (too long to list)

 

Sessions

The session list is not complete yet, but these are currently listed sessions:

 

(Up-to-date list here: http://www.sharepointcincy.com/session-information)

Breakout Session Tracks/Topics

Core topics/sessions are confirmed, remaining sessions will be added based on demand/input from Registrants.

TRACK 1: Driving Business Value With SharePoint

Subject:  Top 10 Ways to Leverage the Value of your SharePoint Investment
Presenter:   Steve Caravajal – Microsoft Corporation, Principal Architect

Subject:  SharePoint Governance
Presenter:   Mike Smith– MAX Technical Training, Senior Instructor and SharePoint MVP

Subject:  Key “Lessons Learned” from Successful SharePoint Projects
Presenter:   TBD


TRACK 2: SharePoint Development and Site Customization

Subject:  Does it Make Sense to Use SharePoint 2010 as an Application Development Platform?
Presenter:   Mario Fulan – ICC, SharePoint Practice Leader and SharePoint MCM

Subject:  How to Develop and Deploy SharePoint Applications and Solutions
Presenter:   Matthew Tallman – Sogeti USA, Manager Enterprise Collaboration Group

Subject:  Integrating Applications with the SharePoint Platform using Business Connectivity Services (BCS)
Presenter:   Jonathan Mast – SharePoint911, Senior SharePoint Developer


TRACK 3: SharePoint Implementation and Administration

Subject:  SharePoint Administration – Deep Dive
Presenter:   Shane Young – SharePoint911, Principal Consultant and SharePoint MVP

Subject:  SharePoint Disaster Recovery and High Availability
Presenter:   Sean McDonough – Idera, SharePoint Products Manager

Subject:  SharePoint Sizing and Capacity Planning
Presenter:   Shane Young – SharePoint911, Principal Consultant and SharePoint MVP


TRACK 4: Business Intelligence and Data Management

Subject:  Data Visualization and Business Intelligence Solutions Using SharePoint 2010
Presenter:   Raveen Rajavarma – Ascendum, SharePoint Practice Leader

Subject:  Case Study: SharePoint’s Role in P&G’s Business Intelligence Solutions
Presenter:   Pat Kern– Procter & Gamble, IT Director

Subject:  Implementing Dashboard Solutions using PerformancePoint Services and SQL Reporting Services in SharePoint 2010
Presenter:   TBD

 

 

.

SharePoint 2010: What does the web part checkbox do?

 

Here’s a question for everyone… What does the checkbox in the web part title bar do?

image

 

In user interface design, checkboxes generally imply the ability to select more than one item at a time, but you can only check one web part at a time:

image

 

Clicking the checkbox while the page is in Edit mode does reveal the web part ribbon tab, but then so does clicking in the title bar of the web part:

image

 

The checkbox might be the hint that that web part is selected, but so does the border that’s added when you click on the title bar.

image

 

Clicking an item in a list web part checkmarks the item, highlights the time, checkmarks the web part and adds a border around the web part!

image

 

 

So… Why the check box?

  • Like an appendix, every web part just has one?
     
  • It’s was part of a planed multi-select feature that was not completed by release time?
     
  • It’s a secret?
     
  • Someone on the SharePoint team thought that it was just cool?
     

If you know… please post a comment below!

 

.

2/20/2011

SharePoint 2010: Color Coded Calendars (updated!)

 

As I’m working on my customization book I am revisiting every one of my past “quick tips”. As I do so I am often finding a better way to do something. I ran into some issues working around the asynchronous loading of calendar events with the article below. After digging more into the code behind the calendar pages in 2010 I have found a much better way to trigger the color coding code, which fixed a few other issues along the way. 

 

The original article, with the updates is here: http://techtrainingnotes.blogspot.com/2010/06/sharepoint-2010-color-coded-calendars.html

 

(An article may be written and published, but seems it is never finished!)

.

2/10/2011

InfoPath 2010: "The following url is not valid"

 

There are bugs, and then there are DUMB bugs!

 

When you try to publish an InfoPath 2010 form to SharePoint, InfoPath may display this error: “The following url is not valid”, even if the URL is valid. The cause?  This Microsoft article says its because InfoPath ignores your URL and instead checks to see if there is a root level site collection. In other words, if you entered http://yourserver/sites/site1, InfoPath checks to see if http://yourserver is a valid site collection. There’s no “rule” that says you must have a root level site collection in SharePoint.

The fix, according to Microsoft… create a root site collection! 

 

DUMB!

 

Did it work? Yes, and the odd thing is I created a site collection without granting the users access permissions and InfoPath was now happy in spite of permissions.

 

For more info see: http://support.microsoft.com/kb/981854

 

 

And while talking about DUMB bugs…

How about this one… try to publish from InfoPath to a server that requires authentication… you get a popup for the username and password with a popup about “Getting site content types”.  You can’t authenticate without cancelling the “getting” of content types. You can’t get content types without authenticating.

DUMB!

Actually this is dumb, but unlikely. In this example the user was in the Member group, but was not a site owner. The first time the wizard asked for credentials it was to confirm that the site existed. The second time was because the user did not have rights to publish. Still… it’s a dumb bug.

 

image

 

.

2/05/2011

SharePoint 2010 Updated IT Pro CHM Help Files Available

 

The Microsoft SharePoint IT Pro documentation team has release a fresh copy of the SharePoint TechNet content as .CHM help files.

 

SharePoint Server: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=3629425d-1505-456e-89e2-ede95f75ffe5&displaylang=en

 

SharePoint Foundation: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c8cf1631-0f48-4a02-a18d-54b04eb7f0a7&displaylang=en

 

Links to CHM files for FAST, Office, Project Server and others: http://blogs.technet.com/b/tothesharepoint/archive/2011/02/04/new-downloads-it-pro-compiled-html-help-files-for-sharepoint-and-related-products.aspx

 

.

KSCEHYK4QFDX

SharePoint Cincy – Major SharePoint Event Coming to Cincinnati!

 

About time!

We now have our own local event!

 

Northern Kentucky University’s Center for Applied Informatics and MAX Technical Training are bringing a major SharePoint event to the Cincinnati area! SharePoint Cincy will be held at the METS Center located in Erlanger, KY. The METS center is near the Cincinnati airport (CVG) and has lots of free parking.

 

See the site for the agenda, speakers and registration: http://www.sharepointcincy.com

 

image

 

Are you, or do you know a SharePoint “guru”?

Are you a SharePoint guru who would like to speak at SharePoint Cincy?  Click here and summit a proposal. Do you have a recommendation for a speaker or a topic?  Then click here and tell us about it!

 

image

1/31/2011

SharePoint 2010 Internet Site Upgrade Watch Out!

 

I was just updating the list of regional SharePoint User Groups on the Cincinnati SharePoint User Group web site. I did a web search for each group, and then clicked the link…

Many of the user group web sites looked to be inactive!

But most likely they had updated from a SharePoint 2007 Team Site to SharePoint 2010 Team Site.

 

SharePoint 2010 Team Sites have two home pages!

 

In SharePoint 2007 Team Sites had a single home page named default.aspx. In 2010 Team Sites have a new home page named Home.aspx that is stored in the SitePages library. But… there is still a default.aspx page in the root of the site.

If you started out with a 2007 site then the search engines indexed your site as http://yourURL/default.aspx. The same is true for most people who bookmarked your site or linked to it from their site or blog. When you upgraded to 2010 your new home page is http://yourURL/sitepages/home.aspx, but most of the links pointing to your site point to /default.aspx.

 

Fix it

 

There are a number of ways to fix this…

  • Add a message to the default.aspx file (using a Content Editor Web Part) that the URL has changed, and please update your links.
     
  • Add some JavaScript to the default.aspx file (using a Content Editor Web Part or SharePoint Designer) that auto redirects to the new home page.
     

.

Cincinnati SharePoint User Group Meeting

 

Next meeting: Thursday February 3, 2011 6:30 PM

 

February's Presentation

Topic: Building an Optimized Internet Business Solution with SharePoint 2010

Abstract: This one hour presentation will cover Microsoft’s Digital Marketing Platform Strategy around: Web Content Management, Social and Web 2.0, Analytics, Commerce, Search and Digital Assets. Using the SharePoint Platform to deliver an adaptive web experience for end-users is a key area of investment for Microsoft to align with the trends in the market and solutions being deployed in various industries.

Presenter: Michele Fiola is a Digital Marketing Platform Specialist with Microsoft, based out of Cleveland. She has been with Microsoft for 6 years as a Solution Specialist focusing on business productivity applications, such as Office and SharePoint. Michele’s 20 year career in the software industry also includes ERP and Plant Floor Automation expertise

Please email point2share@gmail.com for any questions


Meeting agenda

Date:         February 3, 2011, Thursday
Time:         6:00 – 8:00 pm.
Where:       Max Technical Training, 4900 Parkway Dr. #160 Mason, OH. 
                  Click on the link for directions  http://www.maxtrain.com/directions/
Schedule:
6:00 – 6:25 - Socials and Networking - No Registration required
6:25 – 6:30 - Introduction of Agenda and Speakers
6:30 – 8:00 – Presentation

 

.

1/29/2011

SharePoint: Method 'Post' of object 'IOWSPostData' failed - Excel 2010 Excel Import problems

 

Updated… New version of Office, same old problem!  If you get the IOWSPostData error while trying to import an Excel range into SharePoint, then you need to patch an Excel macro file. The same fix for Office 2007 will also work for Office 2010.

 

Click here for the updated article…

 

.

1/22/2011

Book Update

 

Update! The book’s done! 

See here for the update and here for more about the book.

 

 

I made a big mistake during my presentation at the Columbus SharePoint Saturday… I mentioned that I was working on a book and that it would soon be available.  What was that about “the best-laid plans of mice and men?” As an instructor I get to teach up to forty hours a week, and each classroom hour requires three to eight hours of prep time. Over the last few months I’ve had a heavy class load and little free time for the book. (I keep letting work get in the way of hobbies and book writing!)

Several people have been pestering me about “is it out yet?” So let me tell a little about the book and maybe why it’s taking longer than expected.

 

SharePoint® 2007 and 2010 Customization for the Site Owner

by Michael T. Smith

 

There are a lot of books for SharePoint administrators and SharePoint developers, and even a few for SharePoint end users. But there is not much available for the site owner, especially on quick and easy site customization. Over the last five years I have probably trained at nearly a thousand site owners and written a lot blog articles with tips and tricks for site owners. Most of the blog articles were from site owner questions during or after class that really made me think about how to solve the problem without writing custom code. Most of these articles have been fairly short and to the point: add this web part, copy and paste this JavaScript or CSS. Each time I have written one of these blog articles I have wished I had the time to expand the article to explain more about the how and why of the solution, or to explain the logic of how I figured out how to do it so you could create more customizations like the one in the article. So I started writing the book…

The book has these goals: take what I’ve done in the blog articles as a start and then greatly expand the number of tips and tricks, explain how the tricks work, show how they can be expanded to other uses, and provide a few chapters on basic SharePoint, HTML, CSS and JavaScript skills. The first edition of the book fully supports both SharePoint 2007 and 2010 . If you have not upgraded to 2010 yet, you will one day and will want to know how to make sure these tricks still work.

 

About the other 80%

Writing a book fits the 80 / 20 rule. The first 80% of the work takes 80% of the time, and the remaining work also takes 80% of the time.  :-(   My biggest challenge in this project is knowing when to stop. It seems I can always find just one more way to do something, one more trick or one more screen capture. Where possible I’m rewriting each tip to work in SharePoint 2007 and SharePoint 2010, and as often as possible using the same code for both. I’m also adding jQuery versions of some of the examples for those who are already working with jQuery. I’m testing every trick in Internet Explorer 6 to 8 and FireFox and rewriting the JavaScript to work with all of these browsers. (really fun, let me tell ya…)

 

Book Progress

Most of the chapters are finished and are now being proof read by some nasty critics. The cover art still needs to be done. The index needs to be created. When all of that is done, the book needs to be submitted and a test copy printed to see if everything “works”, things like margins, images, cover art, etc.

 

How it will be published

I don’t see this book ever being finished. There’s just too many things I’m learning about SharePoint everyday. Books published though the traditional channels rarely get updated and I want to update the book as needed. So I am going the “self published” route using a service owned by Amazon.com. It will be first released in print format and I hope to move the book into Kindle and other electronic formats as I get time.

 

A supporting web site

The book will have a version number!  (Should I start with a beta release?)  For that and a number of other reasons the book will also have a supporting web site. There you will find all of the source code, a number of the tricks as downloadable web parts along with any new additions. So don’t get upset if you see a version 1.1 of the book after you bought 1.0. The changes will be on the site.

 

Here’s the current, but still incomplete, table of contents:

(This will change over the next few weeks…)

 

+ Chapter 1 - Read Me First
+ Chapter 2 - An HTML Primer
+ Chapter 3 - A CSS Primer
+ Chapter 4 - A JavaScript Primer
+ Chapter 5 - Hacking Tips!
+ Chapter 8 - Web Part Must Knows
+ Chapter 9 - The Content Editor Web Part
+ Chapter 10 - User Interface Customization
+ Chapter 11 - List and Library Customization
+ Chapter 12 - Surveys
+ Chapter 13 - Links Lists
+ Chapter 14 - Task Lists
+ Chapter 15 - Calendars
+ Chapter 16 - Security Tricks
+ Chapter 17 - Sound, Video, Silverlight and Flash!

 

 

Be patient!  I working as fast as I can.    :-)

1/19/2011

SharePoint 2010: Site Title and Icon - Change the Font Size, Face or Hide It

 

Customizing the site title is a bit harder in 2010 than in 2007 as the site title is part of a larger navigation area that includes the title, a "crumb trail" and the View menu. In this article we will look at using CSS to change the font, color or size of the text. Also see here to change how the whole navigation and crumb trail area works.

 

Here's the home page of a site. "Demo Site" is the name of the site.

  image

 

The following shows the title, crumb trail and view menu for a library. "Demo Site" is the title, "Shared Documents" is a library and "All Documents" is both the current view and the view dropdown menu button.

  image

 

Here's a similar site with the view menu clicked:

  image

 

So as you can see, there a lot of pieces to change to customize the title area in 2010. Now lets take a look at what is required to make the changes for a sample like this one by just using CSS:

  image

 

You would most likely want to make this kind of change for an entire site rather than a single page by using a master page edit. If you want to make these changes for a single page just add a text file with the CSS to a library, add a Content Editor Web Part and then link to the text file.  You could also just edit this page in SharePoint Designer and add the CSS to the page.

 

To make your changes available for all pages in your site, add them to the site's master page.

 

Steps:

  1. Open your site in SharePoint Designer 2010 (see Chapter 6)
  2. In the "Navigation - Site Objects" pane click Master Pages
  3. Right-click your site's master page (typically v4.master) and select "Edit in Advanced Mode"
  4. Search for "</head>" and insert your style block before the </head> tag

            image

 

Here are some of the CSS tags to experiment with:

Changing fonts and colors using CSS

Each part of the page can be hidden or changed by using a CSS style. Here are the styles and the parts:

.s4-titlelogo

clip_image002

#s4-titlerow

The entire title row including "I Like It" and "Tags & Notes"

clip_image004

.s4-titletext h1 a

The site title text

clip_image006

.ms-WikiPageNameEditor-Display

Title of any wiki-style page (home page of a Team Site or a page added with "Site Actions, New page"

clip_image008

.s4-titletext h2 a

List/Library name

clip_image010

.s4-titletext h2

Folder name

#zz17_ListTitleViewSelectorMenu_t

Current view and view selector

clip_image012

#onetidPageTitleSeparator

The triangles between the items "clip_image014"

Note: "." indicates a class while "#" indicates an ID

 

To hide everything after the title:

<style>

.s4-titletext h2 <!-- everything after the site title -->
{
display:none;
}

#onetidPageTitleSeparator <!-- The triangles between the items -->
{
display:none
}

</style>

 

Here's a set of sample styles to change the Site Title, the List Name and the View Selector:

<style>

.s4-titletext h1 a <!-- The site title text -->
{
color:Blue;
font-size:24pt;
}

.s4-titletext h2 a <!-- list / library name -->
{
color:red;
font-size:18pt;
}

#zz17_ListTitleViewSelectorMenu_t <!-- current view and menu -->
{
color:green;
font-size:12pt;
}

</style>

And here's the page using the above styles:

image

 

.

1/12/2011

Interesting SharePoint Controls: WarnOnUnsupportedBrowsers

This is the first of a series of articles on “Interesting SharePoint Controls”. For more controls see here.

 

<SharePoint:WarnOnUnsupportedBrowsers>

This control is available only in SharePoint 2010.

 

The SharePoint 2010 master pages include this control to warn users that they are using an unsupported browser (primarily IE 6). The control is used like this by default:

     <SharePoint:WarnOnUnsupportedBrowsers runat="server"/>

and displays this:

    image

“Your Web browser will have problems displaying this web page. Changes to the site may not function properly. For a better experience, please update your browser to its latest version.”

 

Note to branders and master page editors:  IF your redesigned master page is “IE 6 safe” then delete this control from your master page.

Interesting… Microsoft added it to v4.master and admin.master, but not to default.master (the 2007 style master) or to minimal.master. 

 

More info:  (what little there is…)

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.warnonunsupportedbrowsers.aspx

 

 

.

Interesting SharePoint Controls

Recently while reviewing a SharePoint 2010 developer class it occurred to me that the class made no mention of any of the SharePoint controls. So as I get the time I’ll write a description and find a sample or two of use for the more interesting controls. I’ll use this page as a “table of contents” for these articles.

 

These controls are all part of the Microsoft.SharePoint.WebControls namespace.

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.aspx 

 

Here’s the first two:

 

.

1/11/2011

PowerShell to find SharePoint Content Types

 

A few quick PowerShell scripts…

 

Find all lists that support a particular content type:

 

$webs = get-spsite http://yourserver/sites/yoursite | get-spweb 

foreach ($web in $webs) 
{
foreach ($lst in $web.lists)
{
foreach ($ctype in $lst.ContentTypes)
{
if ($ctype.Name -eq "Document")
{ $lst.DefaultViewUrl }
}
}
$web.Dispose()
}

(Can be typed as all one line.)

 

For SharePoint 2007 replace the first line with these three:

    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

    $site = New-Object Microsoft.SharePoint.SPSite(http://yourserver/sites/yoursite)

    $webs = $site.AllWebs

 

 

Find all list items of a particular content type:

 

$webs = get-spsite http://yourserver/sites/yoursite | get-spweb 

foreach ($web in $webs)
{
foreach ($lst in $web.lists)
{
foreach ($item in $lst.Items)
{
if ($item.ContentType.Name -eq "Document")
{ $item.Url}
}
}
$web.Dispose()
}

(Can be typed as all one line.)

 

Get a list of all Content Types in a web:

$site = Get-SPSite http://yourserver/sites/yoursite

$web = $site.RootWeb

foreach ($ctype in $web.ContentTypes) {$ctype.Name}

These examples used the content type’s name property. You could also use the ID property.

 

 

C#

And for completeness, here’s a C# version to find all lists that support a particular content type:

using System;
using Microsoft.SharePoint;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            SPSite site = new SPSite(http://yourserver/sites/yoursite);
            
            SPWebCollection webs = site.AllWebs;
            foreach (SPWeb web in webs) { 
                foreach (SPList lst in web.Lists) { 
                    foreach (SPContentType ctype in lst.ContentTypes) { 
                        if (ctype.Name == "Document") {
                            Console.WriteLine(lst.DefaultViewUrl);
                        } 
                    }
                }
                web.Dispose();
            }
            site.Dispose();
        }
    }
}

 

.

1/10/2011

Reading the contents of a SharePoint library file using PowerShell

 

I recently needed to read the text from a file in a SharePoint library using PowerShell. The only real challenge was converting the return ByteArray into a string. This might be a rare requirement, but just in case someone else might need it.

 

$site   = Get-SPSite http://yourserver/sites/yoursite
$web    = $site.RootWeb
$list   = $web.Lists["Shared Documents"]
$item   = $list.Items[0]
$file   = $item.File
$data   = $file.OpenBinary()
$encode = New-Object System.Text.ASCIIEncoding

$test   = $encode.GetString($data)

Yes, it can be done in fewer steps… but for completeness…

 

For SharePoint 2007 replace the first line with these two:

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$site = New-Object Microsoft.SharePoint.SPSite("http://yourserver/sites/yoursite")

1/03/2011

Cincinnati SharePoint User Group January Meeting

 

http://www.cincinnatispug.org/

 

First meeting of the new year for the Cincinnati SharePoint User Group is Thursday January 6th, 2011.

And if you are in the Dayton area, don’t forget the DAYSPUG meeting on Tuesday January 11th!

 

 

January's Presentation

SharePoint 2010 and Business Intelligence

You’ve got data, probably lots and lots of data across multiple systems. Your end users however want timely access to information to make effective decisions and to monitor and analyze performance. Join us for a high level overview and demonstration of what SharePoint 2010 has to offer end users who have Business Intelligence needs. Topics covered will be:

  • Excel Services
  • PowerPivot
  • Visio Services
  • Reporting Services (SharePoint Integrated Mode)
  • Performance Point Dashboards

 

Presenter: Tavis Lovell


Tavis Lovell is a Practice consultant with Ascendum Solutions, specializing in SQL Server (Integration Services, Reporting Services, Analysis Services) and database design related to transactional or BI implementations on the Microsoft stack. Tavis is also involved with using SharePoint 2010 for content delivery as it relates to Business Intelligence. When he’s not trying to help the world make better decisions, he spends his time either pretending he’s Jimi Hendrix, or falling down the sides of mountains on a snowboard

 

.

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.