Important notice

Please note that this blog is discontinued here. All the posts are also coppied to my new blog at http://boris.gomiunik.net.
Important: Due to large amount of comment spam further commenting has been disabled here. If you wish to send me a comment, plase look up the same post on my new blog and leave comment there. Thanks!

2/29/2008

Sort a List / Document Library view using URL

This one's an add-on to the previous post. Even though it's quite quick to sort items in a List / Document Library view by clicking on the column title, you can do this also by using URL. Just add parameters

?SortField=[Field Name]&SortDir=[Asc / Desc]

Example: to sort by Title descending, type ?SortField=Title&SortDir=Desc

When is it more worth to use URL instead of clicking? When you...

... like typing urls :)
... need to use this in a script
... need to make direct links manually
... don't want to create an extra view just for sorting

Oznake ponudnika Technorati:

2/27/2008

Quickly filter a List/Document Library View using URL

This one's very useful when you're having a lot of items in a list or document library and you need a quick filter.

If you'll select the filter field it can happen that it will load for a long time. So lately I'm using URL. Suppose you have a long list of contacts and you need to find a contact named Boris.

In the AllItems.aspx - view of the page, add parameters

?FilterField1=[Field Name]&FilterValue1=[Value]

You can add more filterfield and filtervalue parameters to apply filters to more fields (FilterField2, FilterValue2, ...)

The only trick is to know the Field Name like it's saved in SharePoint. You can see this in the list settings page (click on a column name and check URL) or just make a manual filter for the first time.

In my case to find a contact with First Name Boris, I'd go to

http://[site_URL]/lists/contacts/AllItems.aspx?FilterField1=FirstName&FilterValue1=Boris

I'm always browsing a document library with filtering by specific document type. So I've created a simple script. Just add a Content Editor Webpart to your homepage, edit its source and add the following code (just update the url to your document library (docLibUrl):

<script type="text/javascript">
function docLib(dropdown) {
  var vtype = dropdown.options[dropdown.selectedIndex].value;
  var docLibUrl = "/Shared Documents/Forms/AllItems.aspx";
  var filterField = "DocIcon"
  if (vtype != 'Select') {
    document.location=docLibUrl+"?FilterField1="+filterField+"&FilterValue1="+vtype;
  }
}
</script>
<select style="margin:10px; 0px;" id="DocumentTypes" onchange="docLib(this)">
<option value="Select">Select document type</option>
<option value="Select">-- Office 2007 --</option>
<option value="docx">Word 2007</option>
<option value="xlsx">Excel 2007</option>
<option value="pptx">PowerPoint 2007</option>
<option value="Select">-- Office 2003 --</option>
<option value="doc">Word 2003</option>
<option value="xls">Excel 2003</option>
<option value="ppt">PowerPoint 2003</option>
<option value="Select">-- Other --</option>
<option value="pdf">Acrobat (PDF)</option>
</select>

Oznake ponudnika Technorati: ,

2/26/2008

Adding Flash animation in SharePoint Blog and other lists pt. 2

This post continues the topic from my first part about embedding Flash videos in SharePoint Blogs where we've learned how to embed one Flash animation or video (or have a lot of work for publishing each flash).  The problem arises if we want to embed more videos and have them displayed automatically.

Since SharePoint is very strict about filtering a LOT of the code out, I've devised a way of passing all the parameters needed for swf object through ID. And how to recognize divs for the swfobject? Using CSS class name.

Here's what we need to do:

1. Have te swfobject.js uploaded to the site.

2. Add the following javascript at the end of the page (or in a Content editor webpart below the posts or list items:

<script type="text/javascript" src="swfobject.js"></script>

<script type="text/javascript">

function embedFlashes() {
    var myLayers = document.getElementsByTagName('div');
    if (myLayers.length>0) {
        var myFlashes = new Array()
        for (i=1; i<myLayers.length; i++) {
            if (myLayers[i].className == 'flashcontent') {
                myFlashes.push(myLayers[i].id)
            }
        }
        var so = new Array()
        for (j=0; j<myFlashes.length; j++) {
            tempParam = myFlashes[j].split('::')
            so[j] = new SWFObject(tempParam[0], tempParam[1], tempParam[2], tempParam[3], tempParam[4], tempParam[5]);
            for (p=6; p<tempParam.length; p++) {
                detail = tempParam[p].split('=')
                so[j].addVariable(detail[0], detail[1])
            }
            so[j].write(myFlashes[j])
        }
    }
}

embedFlashes()
</script>

3. Now in the content you need to edit the HTML code of the body and insert the layers in the following format (note - input parameters are separated by double colon.:

<div class="flashcontent" id="[url_of_swf_file]::[unique_id]::[width]::[height]::[minimum_flash_version]::[background_color]::[flashvar1=flashvar1_value]::[flashvar2=flashvar2_value]...">[Alternate_content]</div>

Let's reuse the sample from previous post and some color coding. To embed

<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/Z2yNzw00mpA&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/Z2yNzw00mpA&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>

Insert the following html to the blog post body:

<div class="flashcontent" id="http://www.youtube.com/v/Z2yNzw00mpA&rel=1::video01::425::355::8::#FFFFFF">Please view this post on my website to display the video.</div>

The rest of parameters are made up - video ID is video1, it requires flash 8 and background color is #FFFFFF - white. Let's do another sample with flashvars - the same video on MSN Video. The Embed code is:

<embed

src="http://images.video.msn.com/flash/soapbox1_1.swf" quality="high" width="432" height="364" base="http://images.video.msn.com" type="application/x-shockwave-flash"
allowFullScreen="true" allowScriptAccess="always" pluginspage="http://macromedia.com/go/getflashplayer" flashvars="c=v&v=d41e1dfd-919b-4d57-89c9-736f9c75db14&ifs=true&fr=msnvideo&mkt=en-US&brand="></embed>

To embed this video you'd use the following HTML code:
 

<div class="flashcontent" id="http://images.video.msn.com/flash/soapbox1_1.swf::MSNVideo01::432::364::8::#FFFFFF::c=v::v=d41e1dfd-919b-4d57-89c9-736f9c75db14::ifs=true::fr=msnvideo::mkt=en-US::brand=">Please view this post on my website to display the video.</div>

And the result:

 

Yeee, working!

Technorati tags: SharePoint JavaScript Flash SharePoint Blog

Adding Flash animation in SharePoint Blog and other lists pt. 1

UPDATE: This is an outdated method. There is a much easier way. See ERTE on Codeplex or ERTE on my new blog.


SharePoint's rich text field is much better than in version 2.0. It even enables to edit the HTML source. But one thing I don't understand is why it filters out the HTML code so much that we can't even embed the Flash animations or videos into the content. This is a major drawback for SharePoint Blog.

Fortunately I've come up with a nearest thing to a remedy. It's using Deconcept SWF object. It will replace an "alternative" content in a layer with a flash animation (this is also a good way to bypass the "Click to activete this control..." issue in IE). 

Let's say we have a blog and a video to embed for example - this one from YouTube. A simple way of doing it - if you have only one video in the page is:

1. Create a document library and upload the swfobject.js (downloaded from author's website) to it (or just upload it to the root of your website with SharePoint Designer).

 

2. Add a blog post and in the body edit the HTML code and insert the following code:

<div id="flashcontent">Please check this post on my website to view the video</div>

3. In the blog homepage and in the post details page (post.aspx), add a Content editor webpart and edit the source. Enter the following code:

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
    var so = new SWFObject("http://www.youtube.com/v/Z2yNzw00mpA&rel=1", "mymovie", "425", "355", "8", "#FFFFFF");
    so.write("flashcontent");
</script>

For comparison I'm pasting also the YouTube's embed code and I'm color coding it to match the script:

<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/Z2yNzw00mpA&rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/Z2yNzw00mpA&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>


For more details on the script and how to add flashvars. Just be sure to have the right path to swfobject.js and to have the right ID of the div and in the script (in the case above: "flashcontent".

This is the result:

 

Unfortunately in the RSS is still showing the alternate content.

 

This is the method of adding only one video per page. You'd need multiple div ids and you't always need to add to the script below. Fortunately I've prepared a way of automating this. More about this... Stay tuned for my next post.

Technorati tags: SharePoint JavaScript Flash SharePoint Blog

2/25/2008

Adding webparts to other SharePoint pages than homepage and webpart page

Recently I wanted to add some text descriptions to the "NewForm.aspx" and "EditForm.aspx". I remembered a trick Pedro Serrano showed me some time ago. It works for SharePoint 2.0 and SharePoint 3.0.

All you need to add to the page are the
 
?PageView=Shared&ToolPaneView=2
 
parameters.

This opens the Task pane for adding webparts. So now you can add any webpart to the page. Some practical uses are to add Content Editor Webparts to the page or related lists,...

Oznake ponudnika Technorati:

2/21/2008

Free Undelete utilities

Not long ago I've had a bit of mishap by deleting some of my very important pictures (birth of my kid). With the first shock I couldn't find quickly any free software for undeleting.

After calming down I've found the following two:

Office Recovery FreeUndelete 2.0

Free Undelete +

They did a very good job and I have my photos back :) I hope by posting these here they'll help someone else too. I'd be glad to hear about similar situations or software in the comments of this post.

Refferencing Hours and Minutes dropdown on "Date and Time" field with JavaScript

I've already posted on how to refference SharePoint field with JavaScript (here - with functio getField).

For "Date and Time" type of fields you can use the above function only to refference the Date part. Thanks to Erik / Tanker who commented my post and discovered that these dropdowns get the same ID but just have added "Hours" or "Minutes" to it I'm posting now the 2 more functions to refference Hours and Minutes with these kind of fields.

There are numerous options - you can merge all together in one function, you can make separate functions, etc. I've decided to make two additional functions:

1. You'll need the getField function I've already posted

2. Add the two following functions:

function getDateFieldHours(fieldTitle) {
    var dateField = getField('input',fieldTitle)
    return document.getElementById(dateField.id+'Hours')
}

function getDateFieldMinutes(fieldTitle) {
    var dateField = getField('input',fieldTitle)
    return document.getElementById(dateField.id+'Minutes')
}

So if you have for example "Start Time" field which is Date and Time you can refference:
- the Date part with getField('input','Start Time')
- the Hours part with getDateFieldHours('Start Time')
- the Minutes part with getDateFieldMinutes('Start Time')

Thanks again, Erik!

Oznake ponudnika Technorati: ,

1/23/2008

"Cannot find c:\...\exportsettings.xml" error when restoring with SharePoint Designer

When making a SharePoint Designer backup of a certain Windows SharePoint Services site it's creating it normally. But when you try to restore the same backup you receive the cannot find ... exportsettings.xml error. After digging a lot around I've discovered that this is actually a SharePoint Designer Bug.

This error occurs if your backup has more than 25 MB. So to move larger sites we're in trouble and we should wait for SharePoint Designer team to fix the bug? Yes. Meanwhile there is a workaround that worked for me. Suppose we want to copy the SharePoint site http://www.mysite1.com/ to http://www.mysite2.com.

We need the following:

1. Access to the server where the SharePoint mysite1 is hosted
2. SharePoint designer (you don't need it installed on the server)
3. Administrative rights to mysite2.com

And the process is as follows:

1. On the server where you have the www.mysite1.com locate the file stsadm.exe (usually in the folder C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN). Copy the stsadm.exe to a location where you'll run it or make %path% to it or go to that folder in the command prompt.

2. Open the command prompt with the location of the file and type the following command (let's say we'll backup to c:\.

stsadm -o export -url http://www.mysite1.com -filename c:\mysite1.cmp -cabsize 1024 -includeusersecurity

This is the EXPORT backup of the site with some additional parameters:
-cabsize 1024 makes the backup file size 1024 megabytes instead of standard 25 (which is the error limit in SPD)
- includeusersecurity remembers the security settings of the sites

3. Copy the c:\mysite1.cmp file to your local computer or where you have the SharePoint Designer installed.

4. You have to have the site collection (or subsite) with deployed Blank site template on address www.mysite2.com. Open the site www.mysite2.com with SharePoint Designer and make a SharePoint Designer restore (how? Read more here)

That should have it working.

Backup, restore and migration of sites on SharePoint 3 pt. 3/3

stsadm -o export and stsadm -o import

To backup:
1. Locate stsadm.exe
2. in Command prompt type stsadm -o export -url http://[url-of-the-web-site-or-subsite] -filename [path and name of the file.dat]

To restore:
1. Create a web application and a site collection using sharepoint central administration. Or you can create a subweb in an existing site collection. In both cases you should use a "Blank site" template.
2. Locate stsadm.exe
3. In Command prompt type stsadm -o import -url http://[url-of-the-web-site-or-subsite] -filename [path and name of the file.dat]

You've probably noticed a difference from a method described n previous post is small (only export and import instead of backup and restore). Also we can see that the order of parameters and their values isn't important.

PROS:
1. You can export (migrate) a subsite
2. If you include parameter -includeusersecurity it keeps the security settings and owner information
3. It doesn't keep the list and sites GUIDs so you can use it to copy a site collection inside of the same content database.

CONS:
1. You need access to the server to run the stsadm.exe
2. It doesn't keep the SharePoint Designer's Data-View-Webparts (again you have to fix them manually - read more about it here.)
3. You loose the meta data (created and modified dates and who created it) by default.

1/21/2008

Backup, restore and migration of sites on SharePoint 3 pt. 2/3

stsadm -o backup and stsadm -o restore

To backup:
  1. On the server locate the file stsadm.exe (if you have sharepoint 2 and sharepoint 3 locate the one in the "12" folder.
  2. Open command prompt and type [path to stsadm.exe\]stsadm -o backup -url http://[url-of-the-web-site] -filename [path and name of the file.dat]

To restore: 
  1. Create a web application (but don't create a site collection)
  2. On the server locate stsadm.exe
  3. Open command prompt and type [path to stsadm.exe\]stsadm -o restore -filename [path and name of the file.dat] -url http://[url-of-the-web-site]

PROS:

It migrates the whole site collection perfectly! All data-view-webparts are preserved, all user rights, meta data, etc. are preserved).

CONS:
1, It keeps the same GUIDS of lists and sites, so you can't use it to create a copy of the site in the same content database. (Example: You have 1 web application and you want to create a copy of the site in the same site collection in the same web application)
2. You can't backup specific subsites - only entire site collection
3. You need to have access to the server to run stsadm.exe

Backup, restore and migration of sites on SharePoint 3 pt. 1/3

SharePoint Designer Backup and Restore

To backup:
  1. Open the site with SharePoint Designer
  2. Select Menu "Site" --> "Administration" --> Backup web site
  3. You can select to backup also the subsites
  4. Select where to save the backup file and write file name

To restore:
  1. You have to have the created blank site (in the same language)
  2. Open the blank site with SharePoint Designer
  3. Select Menu "Site" --> "Administration" --> "Restore web site"
  4. Browse the file from your local computer
  5. After backup is made you can delete SharePoint's temp file on site

PROS:
1. Easy backup, keeps meta data (like "Created" and "Modified" dates, "Created by" and "Modified by") - Even if restoring to different sites. Can migrate between different sub-versions of same WSS 3.
2. You don't need access to the server, just administrative rights on the site.

CONS:
1. A BIG con is that you can make a backup of the sites that have under 25 MB. Looks like this is a bug in SharePoint designer and I hope it will be fixed soon. If you are backing up a site with over 25 MB you will encounter a problem "Cannot find ..... exportsettings.xml". There is a workaround to this (I'll post that in one of my later posts).
2. It doesn't keep any custom data-views created with SharePoint Designer. After you restore and if you have any data-view-web-parts that you've created with SPD and are not working - you have to fix them. Read how to fix them here.

12/01/2007

How to open an Office document in the document library without asking for username and password?

Even if you have the website open for anonymous access and anonymous users can access your documents in a document library, opening an office document will always require entering username and password. You can open the document, if you cancel the request for username and password three times. Still this can be annoying.

Untill now I was avoiding this by publishing PDF documents and making links to them. But you can change this. Let's say we're in a subsite /sub1 and have a Word document called mydocument.doc in a document library called Docs.

Linking to /sub1/Docs/mydocument.doc will request username and password from anyone opening the document. To avoid this, correct the hyperlink in your refference to:
/_layouts/download.aspx?SourceUrl=/sub1/Docs/mydocument.doc
is going to result in a simple download.

Now I can publish also Office documents for public.

UPDATE: Seems I was making the mistake of testing this authenticated. The _layouts/download.aspx requires authentication, so we're still stuck with the same problem. But it doesn't ask for username when opening word :)

11/30/2007

Add Content Editor Web Parts a bit faster

Here's a quick tip: If you want to add more Content Editor Web Parts faster to a homepage or a webpart page (to move and edit them afterwards)

1. Switch to edit mode
2. Add a Content Editor Web Part
3. When the page reloads with a CEWP added, hit Refresh (F5) and click "Retry" when Internet Explorer asks you if to resubmit information.

I use this technique to add multiple CEWPs to the page, when I need to add some explanations above some webparts. When I have enough of them, I drag them to different zones and positions and edit the titles and contents.

11/18/2007

Using Cookies with SharePoint's Data View

In my previous post I've explained how to pass parameters from URL to use in a Data View. There is another very useful way: - using Cookies. The process is very similar, using SharePoint Designer:

1. To read the cookie value and use it as a parameter:

Open the properties pane of the XSLT Data View and select Parameters

Add a parameter, name it as you wish, and in the Parameter Source select Cookie. In the next field enter the name of the cookie which to read and again you can enter a default value.

And you can use the parameter value as you wish - for filtering, conditional formatting, as content in the dataview, etc.

2. But how to set or manipulate Cookies?

The easiest way to set a cookie value is with functions I've found on QuirksMode. I've contacted the author but got no reply so I'll dare to publish the JavaScripts here. I repeat again: these are the property of QuirksMode. I use the functions below to set, change value or delete cookies 


Set or change value of a Cookie:

function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else
    var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

Delete cookie:

function eraseCookie(name) {
    createCookie(name,"",-1);
}

To put the above example into practice. In a DataView I'd be reading a cookie named ShoeSize and use it as parameter $Size in a data view. To set the value of a cookie for example to M I'd use a function:

<script type="text/javascript">createCookie('ShoeSize','M')</script>

If the third parameter is not supplied the cookie is active only as long as the browser is open. To change a cookie value to S and to be valid for 3 days, I'd use

<script type="text/javascript">createCookie('ShoeSize','S',3)</script>

When I don't need the cookie anymore, I just use <script type="text/javascript">eraseCookie('ShoeSize')</script>.

Using cookies to pass parameters between pages has its benefits, like - you don't complicate with codepages, long URLs, you can pass the parameter between more pages than one, etc. But you can't pass the parameter with cookie between sites. For this I'd recomend QueryString.

Using parameters from URL as variables in XSLT Data View

This is a reply to PsychedEric in my post about QueryString. To use params from URL in an XSLT data view is quite simple. Once you have the data view inserted, display the options of the Data View and click on Parameters.

Next click the button "New Parameter" and enter a name for it. Then in a Parameter Source dropdown, select Query String.

 

Under the dropdown enter the variable name - which parameter in URL to read. For example if it will be reading parameter "p" in url webborg.blogspot.com?p=1234 just enter letter p. You can also set a default value if there is no p parameter in the URL.Next click OK.

And that's it. Now you can use this parameter for filtering, or in the Data View Web part as you desire. If you want to use the parameter in the DataView just enter its name with a $ (dollar) sign before it. SharePoint Designer's Intellisense will recognize it.

10/22/2007

New Free Download Manager - Download videos from YouTube, Google Video, ...

I've already posted about the Free Download Manager. Recently I've checked and they have a new version, which enables you to download videos from YouTube, Google Video, Blennus, DailyMotion, LiveDigital and MySpaces. Probably the list of supported sites will keep expanding.

It enables you to automatically convert the downloaded Flash video (.flv) to some of the popular video formats - .avi, .mpg, .mp4, .wmv, etc.

It comes also with a built-in (as an option) torrent downloader.

10/11/2007

Stability and performance update for Windows Vista

Yesterday evening my laptop with Vista already got too slow for normal work that I started to think about reinstalling. But instead I decided to use the performance tools in control panel and I made serious maintenance plus I turned off some features like visual styles.

An improvment in performance was immediate. And then suddenly a baloon pops up from my system tray explaining that there are solutions to my Vista problems (format? :-)). Desiring the better performance I follow the link and download the update. For all here's the link to KB article from which you can download the update for 32-bit or 64-bit Windows Vista.

http://support.microsoft.com/default.aspx/kb/941649

After installing the patch and restart - the difference is obvious. Performance is better.

The best performance improvement I notice is that my SharePoint Designer crashes immediately instead of freezing for 2 minutes first :-)

Technorati Tags: , ,

10/07/2007

Great tools for web developers pt. 3

The third in the series of tools for web developers is for the ones that don't want or don't have the option to install any software or addons and just need a quick access to a tool for inspecting DOM

1. Mouseover DOM inspector v. 2 - MODIv2

This thing is pure JavaScript, DHTML and CSS so you really don't need anything else for inspecting a DOM of a certain page. All you need is to bookmark a link on the help homepage:

Tools For Web Designers Pt. 3 - 01

And then go to the page you want to inspect the DOM, and next just call the script from your favourites.

Tools For Web Designers Pt. 3 - 02

And you're already exploring the DOM.

Tools For Web Designers Pt. 3 - 03

It doesn't contain as many tools as the previously described toolbars, but it's a very good solution for quick start and instant DOM inspection.

Great tools for web developers pt. 2

In my previous post I've presented a tool that I find very useful when debugging display, creating javascript related to HTML DOM, etc. The tool is intended for Internet Explorer. The FireFox users aren't deprived of such tools either. There are two tools available:

 

1. Web developer toolbar for Mozilla Firefox

 

It offers quite a wide array of tools for web developers, such as ruler, css validation, DOM explorer, etc.

Tools For Web Designers Pt.2 - 02

It has a nice feature when exploring DOM - it displays all the parrent elements - so you can see how any element is nested.

Tools For Web Designers Pt.2 - 03

A neat add-on to that feature would be to be able to pause the selection and view the nested DOM, since there are a lot of times too many nested elements and the text goes out of the screen.

2. Firebug

A good combination of both - ie and firefox dev toolbar, it has very good tools for debugging HTML, CSS and JavaScript. What I like about it is that you can select the elements and it automatically also selects the HTML. And to manipulate the HTML, JavaScript and CSS in real time is very easy.

What I like about it is that it is easy to use, it has ability to monitor, debug and execute JavaScript, it helps with visualising some of CSS properties, and its toolset is nicely organized and easy to use. On the image below you can see how easy is to manipulate HTML in real time.

Tools For Web Designers Pt. 2 - 04

The problem of displaying too many nested elements is solvet neatly with a simple solution: the elements are ordered in opposite sense - it displays nested elements from right to left - instead of html > body > ... div it displays div < ... < body < html.

Tools For Web Designers Pt. 2 - 05

These are some neat tools that may make your life easier. I recomend using them all together because you know what headaches the IE/FireFox display compatibility can cause :)

10/04/2007

Great tools for web developers pt.1

Many times to refference or change the the element's properties in a DOM of a web page, I was just going crazy. Especially in SharePoint this can be difficult, because some elements are nested DEEP within other elements (table > div > div > div > ... > input).

You can help yourself a bit with javascript:alert() or by viewing code, but there are tools to make your life as a web developer much easier:

1. Internet Explorer developer toolbar

This tool is a super add-on to Internet Explorer, with which you can easily explore the dom elements and their properties simply by mouse over and click.

Some screen shots

Tools For Web Designers 01 Tools For Web Designers 02

It has lots of other neat features like visual display of class and id info, outlining certain elements, disabling styles, images, clearing temporary files, etc. I especially like the color picker and the ruler, enabling you to select colors or to measure width or height of anything directly on the screen!

Color picker
Tools For Web Designers 04
Ruler
Tools For Web Designers 05