8/18/2015

Cincinnati PowerShell User Group Meeting

 

Register here: (free!) http://www.meetup.com/TechLife-Cincinnati/events/224705451/

Cincinnati PowerShell Users group – August Meeting

When: August 27th
Where: Max Technical Training
Mason, OH

PS C:\> Get-PSUG | where {$_.City -eq Cincinnati}

The Cincinnati PowerShell user group is back and under new management!  Last meeting was great with Ed Wilson as our presenter, I hope you all got as fired up about scripting as we did!

Come join us as we dive into….

Version Control?  That's for Developers, not Admins!!

Does your version control look like this?!?!?

We'll cover different ways to approach source control with PowerShell, why we as System Administrators need it, and why the idea of "infrastructure-as-code" is getting so much traction these days.

 

Sponsor!

SAPIEN Technologies will be sponsoring the Cincinnati PowerShell User Group meeting and will be supplying the pizza!

.

8/16/2015

They just can't leave anything alone! "App" now is "Add-in"???

 

Just as they have gotten everyone to call everything an "app", they have to change it again. Lists = apps, libraries = apps, web parts = app parts… everything was to be an app. Now everything is a "add-in"?

  • "SharePoint apps" are not SharePoint Add-ins.
  • "SharePoint app parts" are now "SharePoint add-in parts"

But strangely…

  • The SharePoint "app launcher" and the "My Apps" page are keeping their old names.

 

Everybody say "Add-In"! Smile

https://msdn.microsoft.com/EN-US/library/office/fp179930.aspx

The name "apps for SharePoint" is changing to "SharePoint Add-ins". During the transition, the documentation and the UI of some SharePoint products and Visual Studio tools might still use the term "apps for SharePoint".

Also see:  https://msdn.microsoft.com/EN-US/library/office/fp161507.aspx#bk_newname

 

 

So… what is an "App"?

List? Libraries?  Not too sure anymore…

Oh well…

.

8/07/2015

Hiding the Evil SharePoint 2013 Share Buttons!

 

SharePoint introduced Share buttons to make it easy for users to quickly share a site, folder or document. This introduced several administration, security and governance problems for administrators. Mostly because the act of sharing a document breaks inheritance on the file. Whether this is "evil" or not depends on the way you need to use SharePoint. 

Here's a sample flow:

  • We have a library for 100 sales documents. Currently the Sales Managers group and five other users have access to the library and its contents.
  • Someone clicks the Share button on a document.
    • If the user is not an owner and does not have the Manage Lists permission, then a request is added to the Site Owners. Site Owners, if they ever discover the request, can approve or reject it.
  • Inheritance is broken on the document. Existing permissions are copied to the file. The user is added to the document's permissions list.
  • Now the fun begins…
    • A new user or group is given permissions to the library.
    • They only see 99 documents! (The missing document has unique permissions and no longer inherits permissions from the library.)

After inheritance is broken you have to remember to manage the permissions of each individual broken inheritance document. Now think about 50 libraries, each with where the Share button has been clicked on a 1000 documents. Job security at the minimum!

 

Just how many Share buttons are there?  
(Let me count the ways…)

The Share the site button:

   image

The Share a document button in the "QCB" (Quick Control Block?) bar:

   image

The Share a document button in the FILES ribbon :

   image

The Share a document button in the "…" pop out:

   image

The Share a document link in the "… …" menu:

   image

The INVITE PEOPLE button in create a new folder:

   image

The Invite People button in the Shared With dialog box:

   image

Did I miss any?

(I started on this article a few times, but each time I found yet another Share button!)

 

Disabling using Views

You can hide the Share button that's just above the library by switching to any other view style than"Default". This also hides all of the other links in the "QCB" (Quick Control Block?) bar.

image

The Share button will be grayed out in the FILE ribbon if you select a Style other than Default and Shaded, or disable "Tabular View - Allow individual item checkboxes".

Disadvantages? These styles do not display a checkbox, even if "Tabular View - Allow individual item checkboxes" is checked. Without the checkbox most of the options in the FILE ribbon are disabled.And… this approach only hides one of the Share buttons.

 

Disabling the Share buttons using CSS

The easiest way, at least until Microsoft gives us an option to turn them off, is to add CSS to the Master Page. Some of the buttons has convenient IDs while some can be found using a class. While you could merge all of the selectors into one line, I broke them out so you could choose which Share features you would like to hide or keep.

In my project I uploaded the CSS file to the Site Assets library. You could place the CSS file in any library where your users have at least read access, or in the layouts folder on the server. You would then link to the file something like this:

<link rel="stylesheet" type="text/css" 
href="https://yourServer/sites/yourSite/SiteAssets/nosharebuttons.css"></link>

Or maybe:

<link rel="stylesheet" type="text/css" href="/_layouts/nosharebuttons.css"></link>

 

The CSS:

/* CSS to hide the various Share buttons and links */
/* from TechTrainingNotes.blogspot.com             */
/* Use at your own risk. Batteries not included.   */

/* Hide Site Share button (page top right) */
#ctl00_site_share_button  {
 display:none !important;
}

/* Hide library toolbar (QCB) Share button */
.js-listview-qcbShareButton {
 display:none !important;
}

/* Hide the Share in the ... popout */
.js-callout-actionsMain span:nth-child(2) {
    display:none !important;
}


/* Hide the Share in the ... ... menu */
a[title="Share"] {
 display:none !important;
}


/* Hide the INVITE PEOPLE button in Create Folder */
#csfd_invitePeopleBtn {
 display:none !important;
}

/* Hide the Share button in the FILES ribbon */
#Ribbon\.Documents\.Share\.ShareItem-Large {
 display:none !important;
}

/* Hide the Invite People button in the Shared With dialog */
#lnkShrItem {
 display:none !important;
}

 

Here's the "one line" version:

/* CSS to hide the various Share buttons and links */
/* from TechTrainingNotes.blogspot.com             */
/* Use at your own risk. Batteries not included.   */


#ctl00_site_share_button, 
  .js-listview-qcbShareButton, 
  .js-callout-actionsMain span:nth-child(2), 
  a[title="Share"], 
  #csfd_invitePeopleBtn, 
  #Ribbon\.Documents\.Share\.ShareItem-Large, 
  #lnkShrItem 
{
 display:none !important;
}

 

.

7/13/2015

SharePoint 2013: Center or Centre? Search knows the US/UK spelling variations!

 

Weird what you stumble across in SharePoint! There is no end to finding things!

Center or Centre? Organization or Organisation? Harbor or Harbour?

SharePoint 2013 search, both On Prem and Office 365, appears to have a US/UK synonym list built-in. I can't find documentation for it anywhere, but it seems to work as expected. Below a few of the words I tested. Search for one and you will find documents with the other.

  • center/centre
  • neighbor/neighbour
  • organization/organisation
  • color/colour
  • flavor/flabour
  • honor/honour
  • caliber/calibre
  • practice/practise
  • license/licence
  • defense/defence
  • connection/connexion
  • realize/realise
  • spelled/spelt
  • analyze/analyse

My editor's spell checker marks all but one of the second terms as misspelled! It seems to like "spelt".

To see a list of these common spelling variations see https://en.wikipedia.org/wiki/American_and_British_English_spelling_differences

 

.

7/09/2015

SharePoint 2013: Hide List and Library Column Headings

 

This is an update to an older article to include support for SharePoint 2013.


Hiding Column Headings

I had a request to hide the column headings of a list displayed in a web part. First thought was that they wanted to hide the toolbar, but they were asking about the clickable column headings. I think they were wanting to make a page look more like a regular web page instead a page full of lists. By the way, this makes for a better way to display a view with only one column.

Note: This will of course remove the ability of the site visitor to sort and filter the web part.

Note: This will also work in the view page (view pages use web parts!), but in SharePoint 2010 and 2013 adding a web part to a view page will change how the ribbon gets displayed and will remove the View dropdown menu from the title area crumb trail.

Before:

image

After:

image

With Toolbar set to "No Toolbar":

image

Remove additional clutter…

You can edit the web part and then click "Edit the current view" further clean up the display of the list.

  • Remove the checkbox column: In the Tabular View section uncheck "Allow individual item checkboxes".
  • Remove the "…": In the Columns section uncheck "Name (linked to document with edit menu)" and checkmark "Name (linked to document)".
  • Remove the hyperlink: In the Columns section uncheck "Name (linked to document with edit menu)" and checkmark "Name (for use in forms)".
  • Remove any unneeded columns such as Modified or Modified By.

image

 

Steps:

  • Add your web part for the list or library to a page.
  • For a minimal look set the web part's Toolbar Type property to “No Toolbar”.
  • Copy the JavaScript below to a Notepad file (name it something like “HideHeading.html”) and upload this file to a library such as Site Assets.
  • In the library where you uploaded this file, click the "…" and copy the displayed URL. It should look something like this:
        https://yourServerDomain/sites/training/SiteAssets/HideColumnHeadings.html
  • Below your list / library web part add a Content Editor Web Part (CEWP).
    • If the CEWP displays it’s title bar then in the Appearance section set the Chrome to “none”.
    • Paste the URL copied above into the Content Link box.
    • In the web part properties editor, click OK.
    • In the PAGE ribbon, click Save.
  • Or (for SharePoint view pages)
    • Edit the view page in SharePoint Designer 2013. 
    • Copy and paste the Javascript to just before the end tag for PlaceHolderMain (just before </asp:Content>).
  • If you want to hide the column headings of multiple web parts modify the IF statement like this Three web parts

Web part summary name!

In SharePoint 2007, the summary name is usually just the list’s name: “Shared Documents”.

In SharePoint 2010, the summary name is usually the list’s name PLUS the list’s description. For example the default for Shared Documents is: “Shared Documents Share a document with the team by adding it to this document library.”  (including the period)

To find the correct name use your browser’s View Source option to display the HTML of the page and search for “summary=” and copy the text that follows. Or, use the browser's developer tools (usually F12) and search for "summary="

    <table  …  summary="Shared Documents Share a document with the team by adding it to this document library."   … >

 

The JavaScript

Need to change multiple web parts? Edit the line that contains "if (x[i].summary==""

Two web parts:
             if (x[i].summary=="Tasks" | x[i].summary=="Shared Documents"
Three web parts:
             if (x[i].summary=="Tasks" | x[i].summary=="Links" | x[i].summary=="Shared Documents"

<script type="text/javascript">
// CEWP trick from techtrainingnotes.blogspot.com!

// techtrainingnotes.blogspot.com/2015/07/sharepoint-hide-list-and-library-column.html
// Hide column headings in web parts

function TTNHideHeadings()
{
  //Find the list  (change "Documents" to your web part's "summary" name)
  var x = document.getElementsByTagName("TABLE"); // find all of the Tables 
  var y;
  for (var i=0;i<x.length;i++) 
  {
    if (x[i].summary=="Documents")  //find the table with this name
    {
      y = x[i].getElementsByTagName("TR");
      y[0].style.display="none";  //hide the first row
    } 
  }
}

try {
  // for 2010 and 2013
  ExecuteOrDelayUntilScriptLoaded( TTNHideHeadings, "sp.js" );
}
catch (e) {
  // for 2007
  _spBodyOnLoadFunctionNames.push('TTNHideHeadings');
}
  
</script>

7/06/2015

Using SharePoint Search To Find Sites You Have Access To


Did you ever wonder if there's more to SharePoint? Sites you may have permissions to, but no one ever told you about? Sites like the rumored jokes site and the "free stuff" site? You can use search to find these sites!
ContentClass is a SharePoint 2013 Managed Property that is used to find many SharePoint things by their "type". Two ContentClass values of interest when searching for sites are "STS_Site" and "STS_Web".
Tip: For more on what you can do with ContentClass see SharePoint Power Searching Using ContentClass and also here: http://techtrainingnotes.blogspot.com/2015/02/sharepoint-2013-list-and-library.html

STS_Site

The STS_Site property is used to find site collections, or actually just find the top level sites of site collections. To list all of the top level sites that you have permissions to see, search for "ContentClass:STS_Site". (See warning below!)
image
My test user Sam found 8 site collections and my administrator account found 38.

STS_Web

The STS_Web property is used to find subsites. To list all of the subsites that you have permissions to see, search for "ContentClass:STS_Site". (See warning below!)
image
Sam found 9 subsites while my administrator account found 158.

Find all sites you have access to…

Just combine both searches with an "OR" to show all of the sites you have access to. (Remember that Boolean operators like AND, OR and NOT must be in UPPER case.)
image

Adding Keywords

A little tip: If you add keyword to your STS_Web and STS_Site queries you will not be searching content in the site. You instead will be searching for that keyword as a property of the home page or content that might be displayed on the home page. The following search will only return results when "plane" in somewhere on the home page of the site:
image

Warn'n matey, here be dragons, or at least duplicates…

SharePoint 2013 search hides duplicates by default and treats many of the things returned by STS_Site and STS_Web as duplicates. Over half of my subsites are missing using an out of the box search! Administrators can fix this little issue by following the "Option 2" steps here: http://techtrainingnotes.blogspot.com/2015/04/sharepoint-2013-search-weirdness-part-1.html.

STS_Site <> SPSite

A note to developers and administrators: SPS_Site is not the same as SPSite. It's actually finding SPWebs, but only finding those that are top level webs.

.

6/30/2015

SharePoint 2013 Search Weirdness – Part 4: More Duplication Weirdness

 

A continuation of the "Search Weirdness" series!

How many Announcement Lists do I have?

In the first article of this series I showed how something like a series of Purchase Orders that differ in only the PO number, date and a few other details can appear to SharePoint 2013 search as duplicates and be excluded in the default search results. I have found something stranger… it seems that sometimes all Announcement lists look the same to search and are also treated as duplicates. Lists!

As an example, I did a search to find all Announcement lists using ContentClass:STS_List_Announcements and found only 8 in my entire test farm.

   image

I then edited the search results page and changed the duplicates setting (steps here) and then found all 23 of the Announcement lists.

   [image%255B35%255D.png]

I duplicated the issue in both a test farm (15.0.4649.1000 June 2014 CU) and in the today's version of Office 365. Going forward I'm recommending that the "Remove Duplicates" feature be disabled on all search result pages. Now all I need to do is write a PowerShell script to do this.

 

Another Test

Just in case it has something to do with the Enterprise Search Center, I tried the test using "This Site" in a site that had two announcement lists, one titled Announcements and the other titled Jokes. The search only found one list. Note that in the refiner section there are two authors listed. If I click Sam then I can see the Jokes lists while if I click Mike I can see the Announcements list. But never both! The refiner seems to know that they are both there.

image

_layouts/15/osssearchresults.aspx

The problem with this duplicate problem is that the "This Site" search sends me to the _layouts/15/osssearchresults.aspx page, which is not customizable with Edit Page. I have no place to turn off the "Remove Duplicates" feature!

 

Solution?

In the Enterprise Search Center, edit each results page to turn off the "Remove Duplicates" feature. For "This Site"… tell the users to use "Everything" instead, which redirects them to the Enterprise Search Center.

If you need to restrict the "Everything" search to a single site then use this:

   contentclass:STS_List_Announcements   site:yourserver.sharepoint.com/sites/training

Fun……………………

 

.

6/17/2015

SharePoint 2013 Search Weirdness – Part 3: When do Daily and Weekly Search Alerts Get Sent?

 

A continuation of the "Search Weirdness" series!


 

Search Alerts are Different!

Unlike list and library alerts:

  • You cannot create them for other people. There's no place to type an email address.
  • You cannot request an immediate alert.
  • You cannot pick a time:

List / Library alert options:

image

Search Alert options:

image

 

So when are they run?

You would assume (always a dangerous thing to do) that Daily and Weekly summary search alerts would get created overnight. Turns out they get sent at an exact time, but a different one for each alert!

While working on a new SharePoint 2013 search class I was trying to find out which timer job created the alert emails and if I could set the time they are sent. TechNet documents only a single timer job, "Immediate Alerts", that runs every five minutes. While I could change that interval, I could not find an option for the "nightly jobs". Turns out there isn't any such thing.

I had always assumed (again, dangerous) that these ran overnight. The only documentation I had found in TechNet only said this:

"The daily alerts will have a 24-hour day, date, and time span calculated and stored in the respective database table. A weekly alert will have a seven-day day, date, and time span calculated and stored as part of the individual alert record."

It just says "calculated" and does not say "when". Then I ran across this blog article by Chris Domino and the light bulb went off:

http://www.chrisdomino.com/blog/post/The-Truth-About-How-Daily-SharePoint-Alerts-Actually-Work

When you create a daily alert it is scheduled to run every day at the time you created the alert. I.e. You created the alert at 2:00PM, it will processed every day shortly after 2:00PM. The same applies to weekly alerts. You created the alert at 2:00 PM on a Tuesday, it will be processed every Tuesday at 2:00 PM. I went out and looked as the SQL tables (never do this at home!) and there it was, to the minute, scheduled 24 hours or 7 days in the future.

 

But that's for an on premise SharePoint installation. Office 365 is different!

In my Office 365 tenant my daily alerts are initially scheduled 17 hours in the future and then every 24 hours after that. My guess is that Office 365 is using GMT. So when I schedule a daily alert at 3:45 PM it runs 8:45 AM every day. Five hours off. Hum…  would that mean my tenant is running in Central time? Don't know… just guessing…

 

Another day… another new thing to discover…

 

.

6/16/2015

SharePoint 2013 Search Weirdness – Part 2: Can't Find My Videos!

 

A continuation of the "Search Weirdness" series!


 

Can't Find My Videos!

I have a bunch of videos in my site. They could be anywhere:

  • A document library
  • An Assets library
  • An Office 365 Video Portal
  • An attachment to a list

How do I find them?

 

By File Type?

So to try to find them all I try this search:

image

But…
image

Ok, that was because the "wmv" file type is not in Central Administration's list of File Types. As we cannot change that in Office 365, we need a more universal method. So how about:

image

Ok, now I have results! But… only 12 files, and I know I have many more!

 

By the file extension alone?

What if we just search for "WMV"? Well, it depends… First, that's just one of the possible video extensions. Second, you will find any file that has those three letters, such as an acronym. But… (there's always a "but") In Office 365 / SharePoint Online the file extension is not indexed in Asset libraries. Strangely, with 2013 On Premise the text "WMV" is indexed, but not as a file extension. I.e. you can find the Asset library videos using "WMV", but not "SecondaryFileExtension:WMV".

image

Ok, found a few more files!

 

By Content Types?

That's a good idea, but this will not find videos assigned a default content type (like those uploaded using drag and drop) or stored as list attachments. Also, the "video" content type is used in Asset libraries, not in Video Portals.

image

Or better, use the video content type IDs:

ContentTypeId:0x0120D520A808* OR ContentTypeId:0x010100F3754F12A9B6490D9622A01FE9D8F012*

The first content type for "Video" as found in the Asset libraries. The second content type is for the Office 365 Video Portal videos. The "*" is added to include any content types you create that inherit from these two.

 

By File Name?

Ok, I know the file name of one of the videos, and I know people have uploaded it to multiple sites… So let's try a name search.

image

Found some files!  These were found in a document library, an Assets library and an Office 365 Video Portal. But… only three, and I know there are more.

As the file name is relatively unique, let's try just that…

image

Ok, now I have found four of the airshow2 videos. Where did the extra one come from? The new file is from a folder in the same library. I think SharePoint saw it as a duplicate and ignored it the File Name search, but for some reason displayed it in the "name without extension" search. (See What's a Duplicate?)

But's there at least two more hanging around. one is an attachment to an announcement, and will not be found by file name! The other was uploaded to an Asset library and the user gave it a new "title" while uploading it. The real file name is buried there, but search does not see it. (See SharePoint 2013 Asset Library Secrets!)

 

What about a "Videos" search?

The Enterprise Search Center adds a "Videos" search vertical.

image

This search also found four of the videos by that name, but also missed the attachment. The Local Video Results Result Source uses two content types and nine file extensions to try to find videos.

(
 ContentTypeId:0x0120D520A808* 
 OR ContentTypeId:0x010100F3754F12A9B6490D9622A01FE9D8F012* 
 OR (
     SecondaryFileExtension=wmv OR 
     SecondaryFileExtension=avi OR 
     SecondaryFileExtension=mpg OR 
     SecondaryFileExtension=asf OR 
     SecondaryFileExtension=mp4 OR 
     SecondaryFileExtension=ogg OR 
     SecondaryFileExtension=ogv OR 
     SecondaryFileExtension=webm OR 
     SecondaryFileExtension=mov
    )
)

Notes: The first content type for "Video" as found in the Asset libraries. The second content type is for the Office 365 Video Portal videos. The "*" is added to include any content types you create that inherit from these two.

 

What's going on here???

File extensions:

  • The common video file extensions are not in the default list of files types used by search. So FileType:wmv will not work.
  • While an on premise admin can add these extensions to the search service, Office 365 admins cannot.
  • Use the SecondaryFileExtension property when searching by file extension.
  • Searching by file extension is not useful when the videos are stored as an attachment or in an Asset library.

File names:

  • Search does not index the file name for attachments.
  • Files uploaded to an Asset library and renamed by the user will not be seen by search by the original file name. (Even though the file still has the original name!)

Attachments:

  • The content of an attachment gets merged with the content of the item and are indexed as a single entity. As a video generally has no useful text content, it will not usually be found by search when attached to a list item.

 

Best Practices?

  1. Use good governance to encourage a single way to store videos. Whether that is a Video Portal in Office 365 or an Asset library when on premise. It probably does not matter where, as long as there is a consistent way to find videos. Avoid storing videos in regular document libraries.
  2. Use Asset libraries when metadata and a convenient player/viewer is needed.
  3. Use a Video Portal when using Office 365 / SharePoint Online AND metadata is not important. The only "metadata" is the channel the video is uploaded into, the title and the description.
  4. Consider using a Video Portal as the content is stored in Azure instead of SharePoint and distributed as a CDN.
  5. Never store videos as attachments. Add a link in the task or announcement to a video in a library or Video Portal.

 

Office 365 Notes

Rule #1 for Office 365, like the weather in Cincinnati, if you don't like it, hang around. It will change. Anything written here about Office 365 is subject to change.

The Video Portal is not a pure SharePoint environment.

  • The videos are not stored in SharePoint libraries. They are stored in Azure
  • You cannot create views, add columns or customize the metadata. The only properties are the title and the description.
  • Searching for videos in SharePoint will find videos in the Video Portal, but only by the name, filename and description.
  • Videos are played using Flash or HTML5. (Asset libraries use Silverlight!)
  • The Video Portal will probably change. (See Rule #1)

 

Want to see more about what happens to your video file when you upload it to a Video Portal? Watch this video: https://www.youtube.com/watch?v=HXSZ0jYBKlM

 

 

.

SharePoint 2013: Create a Quote of the Day Web Part (a CEWP trick!)

 

This is a 2013 version of the 2007 and 2010 article found here: http://techtrainingnotes.blogspot.com/2010/10/sharepoint-create-quote-of-day-web-part.html

 

Quote of the Day / Tip of the Day

Want to display some “wise words” for your coworkers? You need a Quote of the Day web part!

image

You could display a picture or product of the day:

image

 

This web part is another simple Content Query Web Part solution similar to the ones found in my SharePoint 2010 Customization book. But… this one is for 2013!

  • Works from a normal SharePoint list.
  • Displays a random quote from the list.
  • Can display a new quote on each page view, or just one new quote a day.
  • Can be used to display quotes, product announcements or any kind of text, pictures or other content that you can add to a SharePoint rich text editor column.

 

Create the Quotes list

While you could use a Custom List, I used an Announcements list as it already had what I needed, a Title field and a Rich Text field.

  1. Go to Settings (gear) and click Add an App.
  2. Find and click Announcements.
  3. Add a name for the list such as “Quotes”.
  4. The description is optional, but is best left blank as it adds a little complication later on.  (I.e., don't click Advanced Options and add a description!)
  5. Click Create.
  6. If you are not using the Announcements list type then from the list’s Settings menu click Create Column and add a “Multiple Lines of Text” column. Name the column “Quote” (although any name will work) and click “Rich text (Bold, italics, text alignment).
  7. Add a few quotes by clicking "new announcement" or New from the ITEMs ribbon. You can use all of the rich text formatting options if you like. (Bold, colors, etc.)
  8. Create a new view by clicking the Create View link in the LIST ribbon.
  9. Create the view as a Standard view and name it something like “QuoteView”. Un-checkmark all columns except for “Quote” column (the “Body” column if using an announcements list).
  10. Expand the Tabular View section (scroll down to find it) and uncheck "Allow individual item checkboxes".
  11. Click OK.

You now have the list that will store the quotes. You will now add two web parts to a page. One which is the list of quotes, and the other which is a Content Editor Web Part with the JavaScript and HTML code.

 

Add the Quotes list web part to the page

  1. Go to the page where you want to add the “Quote of the Day”, most likely your home page. 
  2. Click Settings (gear), Edit Page.
  3. Click where you would like to add the quotes.
  4. In the INSERT ribbon click Web Part and add the web part for the quotes list.
  5. In the web part click dropdown arrow and then Edit Web Part.
  6. Select the view you created above (“QuoteView”).
  7. Click OK.

This web part will be hidden when the JavaScript runs.

 

The JavaScript and HTML file

  1. Open Notepad or your favorite HTML editor.
  2. Copy the sample code from below and paste into your editor.
  3. Either delete my sample <style> block (it displays the quote in red) or customize your own style.
  4. Find the line with "var quotesWebPartName=" and change "Quotes" to your list's name.
  5. (Optional) Find the line with "var OneQuotePerVisit = false" and change it to true so the user can only see one quote per day.
  6. Save the file.
  7. Upload the file to a library where all of your users have at least Read or View access. "Site Assets" is a good choice.
  8. Find the URL of the uploaded file by clicking the "…" next to the file name. Copy the URL so we can paste it into the CEWP below.

 

The Content Editor Web Part

  1. Add a Content Editor Web Part (CEWP) and move it so it is near the quotes web part. While the list web part can go anywhere, the CEWP must go where you would like to display the quote of the day. 
  2. Click the CEWP’s dropdown menu and select Edit Web Part.
  3. Paste the URL you copied earlier into the Content Link box.
  4. In the Appearance section add a title for the web part (perhaps “Quote of the Day”).
  5. At the bottom of the web part properties box click OK.
  6. Save your page and test! Refresh the page to see if the quote changes.

 

 

The JavaScript

Copy and paste the following JavaScript into Notepad or your favorite HTML editor. (see above)

<!-- add your own formatting here... (optional)-->
<style type='text/css'>
  #TTNQuoteText { color:red }
</style>


<!-- Quote will be displayed here -->
<span id="TTNQuoteText"></span>



<script type="text/javascript">

function TTNShowQuote()
{
// another CEWP trick from http://TechTrainingNotes.blogspot.com
// http://techtrainingnotes.blogspot.com/2010/10/sharepoint-create-quote-of-day-web-part.html

// name of the quotes library web part
  var quotesWebPartName="Quotes"; 


// set this to "true" so the user will see the same quote 
// for 12 hours or until they close and reopen the browser
  var OneQuotePerVisit = false;



// don't change these
  var QuoteList;
  var QuoteArray = [];
  var quoteCount = 0;

  var TTNTables = document.getElementsByTagName("TABLE");
  var i=0;
  for (i=0;i<TTNTables.length;i++) 
  {
    if (TTNTables[i].summary)
    {
    if (TTNTables[i].summary == quotesWebPartName)
    {
      // Get the table with the quotes
      QuoteList = TTNTables[i].getElementsByTagName("tbody")[0];

      // hide the links list web part, but only if not in edit mode
      if (PageState.ViewModeIsEdit != "1")
      {
        QuoteList.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display="none"; 
      }
      break;
    } 
    }
  }

  if (!QuoteList)
  {
    document.getElementById("TTNQuoteText").innerHTML="Web Part '" + quotesWebPartName + "' not found!";
  }

  //Count the quotes
  var links = QuoteList.getElementsByTagName("TR") // find all of the rows
  var url;
  var quoteCount = 0;
  for (i=0;i<links.length;i++) 
  {
    
    //if (links[i].childNodes[0].className=="ms-vb2")
    //{
      QuoteArray[quoteCount] = i; 
      quoteCount++;

    //}
  }
  
  if (quoteCount==0)
  {
    document.getElementById("TTNQuoteText").innerHTML="No quotes found in web part '" + quotesWebPartName + "'!";
  }

  var id=-1;

  // check for a cookie and use last ID if found

  if (OneQuotePerVisit)
  {
    // check for a cookie with the last quote ID
    if (document.cookie.length>0)
    {
    c_start=document.cookie.indexOf("LastQuoteDisplayedID=");
    if (c_start!=-1)
      {
      c_start=c_start + "LastQuoteDisplayedID".length+1;
      c_end=document.cookie.indexOf(";",c_start);
      if (c_end==-1) c_end=document.cookie.length;
      id = unescape(document.cookie.substring(c_start,c_end));
      }
    }
  }

  if (id == -1) 
  { 
    // generate a random quote ID
    id = Math.floor(Math.random() * QuoteArray.length) 
  }
  // display the quote
  document.getElementById("TTNQuoteText").innerHTML= QuoteList.getElementsByTagName("TR")[QuoteArray[id]].childNodes[0].childNodes[0].childNodes[0].innerHTML;

  if (OneQuotePerVisit)
  {
    // set a cookie so they see the same quote for xx hours (.5 = 1/2 day = 12 hours)
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + 1);
    document.cookie="LastQuoteDisplayedID=" + id //+ ";expires=" + exdate.toUTCString();
  }


}


// add our function to the SharePoint OnLoad event
_spBodyOnLoadFunctionNames.push("TTNShowQuote");


</script>

 

Only have about 100 more of these to update from 2007/2010 to 2013!

 


.

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.