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!
Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

9/07/2008

Making "Post" and "Get" forms from SharePoint’s pages

Recen project we were working on needed some forms to be posted to certain services. Knowing that SharePoint's pages are one big form and you can't nest another form inside another this starts becoming a problem.

But I remembered a while ago I was watching how the guys over at MSN spaces did it with the "Blog this" functionality. So based on this I've made similar script and methodology so you can create "forms" that make POST or GET from within SharePoint's Pages. The script is not fully automated, since it directly works only in IE, but with minor additions specific to your form, you can get it working easily in other browsers also.

Read all about it over at my new blog

.

9/03/2008

Group items in a data view with the ability to nest items

In case you've missed it I've written a new article over at my new blog, which shows step-by-step process to group items. The difference between this method and the method the SharePoint Designer uses is - you can use nested elements (like nested lists, nested divs, etc.), which is fantastic for some navigation items, etc.)

See how to group items a bit differently over at my new blog

Oznake ponudnika Technorati: ,,,

8/14/2008

SharePoint Conference in Slovenia

B4Contact, the company where I work, is preparing an event that will take in my home town, Murska Sobota:



Display bigger map
 
Apart of knowing this beautiful part of our planet the event will open opportunities for cooperation between Microsoft partners from Slovenia and neighboring countries as Italy, Croatia, Hungary, Austria and other European countries.
 
It will be also a good opportunity to see which solutions are available for SharePoint!
 
I will have a presentation there, of course, but I will not tell you about it yet.

Here comes another nice part: If you think you could be a speaker, please let me know by adding a comment. I would love to get to know in person some of you!

More details will follow

7/30/2008

Deployment of ERTE

There were some questions about how to deploy the ERTE solution that I've prepared on Codeplex (for inserting embeddable content to SharePoint Enhanced Rich Text Field). So I've prepared a video on how to deploy it.
 


Oznake ponudnika Technorati: ,,,

7/24/2008

Couple of useful JavaScript global variables in SharePoint

If you're using custom JavaScripts with SharePoint some global JavaScript variables may come in handy.

These variables work if you're using SharePoint's default or any other custom master page.

L_Menu_BaseUrl - the base URL of the site / subsite. Very useful when you need to determine the absolute path of the site in JavaScript. Example: document.location = L_Menu_BaseUrl + 'lists/calendar/allitems.aspx' //redirects to Calendar list

L_Menu_LCID - the LCID of the site you're in. Useful if you need to determine the language of the site. The list of Locale IDs can be found here. I'm using the LCID for localizations in ERTE project. See the example of checking LCID below:

.
L_Menu_SiteTheme - the name of the theme applied to the site.

There is one more useful variable, but this one can't be used on custom master pages that you created. This one is used in the SharePoint's default pages:

_spUserId - the ID of the logged in user.

Oznake ponudnika Technorati: ,

7/23/2008

New Release of ERTE for SharePoint now supports localizations.

The new version is released. If you've downloaded the first release, just download the new one from CodePlex and replace the .js file in the /_catalogs/masterpage gallery in your site collection. The project is still under Beta, so if you find some bugs please let me know.


The new version now supports localizations. The current version is published with English (LCID 1033) and Slovene (LCID 1060) translations. If the script can't find localization for your language, it will use english by default.

To add your own localization, add under "//Localization arrays" the translated following line:

var erte1033 = new Array("Please inputtt details","Alt Text","This will be displayed in RSS feeds","Embed Code","Paste your Embed code here","Insert","Close"); //english

and change the LCID and language at the end. If you don't know the LCID of your SharePoint site, open it in Internet Explorer, in the address bar type javascript:alert(L_Menu_LCID) and press enter. The alert window will tell you the LCID. The final translated version (example for Slovene language) will look like this:

var erte1060 = new Array("Vnesite parametre","Besedilo","Besedilo bo izpisano v RSS-viru","Embed koda","Prilepite Embed kodo v polje","Vstavi","Zapri"); //slovene

If you've localized the texts, I'd be happy to add them to the new release, so we could have as full version as possible. Please publish the translation under comments on my CodePlex HomePage.

Oznake ponudnika Technorati: ,,,,,

7/11/2008

Just released: Enhanced Rich Text Field Extended

I was already writing and showing how to embed Flash animations in a SharePoint Blog or any Enhanced Rich Text Field.

Watching MIke Gannotti's video about what I was already presenting he had a good point, the solution is not so user-friendly.

So I changed the methodology a bit. Now the simple-to-deploy solution offers the following features:

1. Embed almost any HTML code snippet
2. Additional button in the Rich Text Toolbar to help you embed

3. A User Interface for pasting the code snippet

No server-side code is included. To see more and download the JavaScript please visit

http://www.codeplex.com/erte

The deployment instructions are on the homepage and in the release zip file.

Oznake ponudnika Technorati: ,,,,

4/04/2008

Add functions and events to SharePoint form fields

Do you sometimes wish to make some special form validation or other javascript actions on SharePoint form fields (like for example onchange, onfocus, onblur, etc?). You can add special functions on events to the SharePoint form fields using JavaScript. All you need to do is

1. Write your JavaScript function
2. Use the getField function I was writing about to refference the SharePoint Fiedl
3. write the following code:

getField('[field_type]','[field_title]').[event] = function() {[function_name]};

Let me demonstrate in an example below. I have a SharePoint List with a field "Menu" that is a lookup field to Title list "Menu". I've created another field "Menu_id" that is a lookup to the same list, but instead of Title it should select the ID. These two fields need to select the same item from the list Menu.

 

Now we'll prepare a one-way synchronization. We'll want those two fields synchronized when selecting the item from the "Menu" dropdown. So we'll add an "onchange" event to the "Menu" select field.

1. Add a Content Editor Web part to the page using this method

2. Edit the Source of the content editor web part add the script code, insert the getField function, write your function and use function above. The full code is below

<script type="text/javascript">
function getField(fieldType,fieldTitle) {
    var docTags = document.getElementsByTagName(fieldType);
    for (var i=0; i < docTags.length; i++) {
        if (docTags[i].title == fieldTitle) {
            return docTags[i]
        }
    }
}

function syncDropDowns() {
selectedId = getField('select','Menu').options[getField('select','Menu').selectedIndex].value;
for (i=0; i<getField('select','Menu_id').options.length; i++) {
  if(getField('select','Menu_id').options[i].value == selectedId) getField('select','Menu_id').options[i].selected='selected';
}
}

getField('select','Menu').onchange = function() {syncDropDowns()};

</script>

This is an example made with CEWP and in the SharePoint. The same works also in the Data View Webpart.

Oznake ponudnika Technorati: ,

3/17/2008

Reordering items in data view

A links list in SharePoint has an interesting functionality - to change the order of items.

I've tried and this functionality can be applied to all the lists and used in a data view. Let's go in order.

To reorder the list go to _layouts/reorder.aspx?list={list_guid} in the same site. If you don't know the list guid, go to list settings and replace listedit.aspx with reorder.aspx. You'll go to the interface to reorder items in that list:

 
The change will not be visible in SharePoint's AllItems.aspx page.
 

To sort items in the data view according to ordering you just made:

With data view inserted to the page the first thing we need to do is add the order field to the data view fields. To do this click the list name in the task pane Data Source Details
 

Next click button Fields, find and select Order in the left column and click Add.
 

Click OK to confirm the changes and close the Data Source Properties dialog by clicking OK again. Now you select data view Sorting (in Common Data View Tasks select Sort and Group) and you can choose Order. If you can't find Order in the dialog box, click the last option (Add Sort Expression) and click Add.
 

In the next dialog box, you can select Order from the fields.
 

Now confirm all the selections by clicking OK to close all dialog boxes.

That's not all. Now it's sorted according to order number, but the XSLT is taking this like a text. So we have to fix this. In source code, find <xsl:sort select="@Order" and add a data-type="number" parameter to it.
 

That's it. Now you have items sorted according to the ordering you've made.

What I usually like to add to the data view is a link to reorder items. Just add a footer and in the footer add a hyperlink to the reorder page (the one mentioned at the beginning).

Oznake ponudnika Technorati: ,,

3/08/2008

SharePoint site and multiple domains - alternate access mappings is the way

This is an update to one of my older posts - SharePoint 3 is bound to host headers - I was explaining the problem how the SharePoint binds itself to one host header and a simple trick to avoid this. There is a better way to add another host header to the web application:

On the Server in SharePoint 3.0 Central Administration select Operations tab and select Alternate Access Mappings under Global Configuration.
 

 
Now change the web application you want to edit public URLs for by using the dropdown on the right hand of the page
 

Next click Edit Public URLs
 

And now enter full URLs (including http:// or https://. You can add up to 5 URLs to which the web application will respond


 

At the end also add the host headers to the Website in the Internet Information Services manager.

Note that this works on the web application level. If you have site collections with custom URLs you can't configure multiple URLs for each of these (or if someone know the way, I'd appreciate if you left me a comment).

Oznake ponudnika Technorati: ,

3/04/2008

Navigating through SharePoint Site using URL

I like to access lists, document libraries directly instead of visiting site or subsite and then clicking my way around. SharePoint has very logically structured URLs. Here are some of the most common:

To access: Type url http://[URL]+
Lists /lists/[List name]*
List New Item form [list URL] + NewForm.aspx
List item details (display) [list URL] + DispForm.aspx?ID=[item ID]
List item edit [list URL] + EditForm.aspx?ID=[item ID]
Document Libraries /[Document Library Name]*
Document library upload [DocLib url] + /Forms/Upload.aspx
Document library item details [DocLib url] + /Forms/DispForm.aspx?ID=[item ID]
Document library item edit properties [DocLib url] + /Forms/EditForm.aspx?ID=[item ID]
Special SharePoint pages http://[URL]+/_layouts+
View all site content viewlsts.aspx
Recycle Bin... recyclebin.aspx
Site Collection's recycle bin adminrecyclebin.aspx
Create create.aspx
Site Settings settings.aspx
New Subweb newsbweb.aspx

* in cases of Lists and document libraries only spaces get preserved (and translated in %20 in url). Special characters are excluded (for example: list Special Čheck url would be http://[sute url]/lists/Special%20heck/

These things are quite obvious. What I'm trying to point out is if you're accessing certain lists/document libraries/settings often, it's not a bad idea to start paying attention to URLs.
Oznake ponudnika Technorati:

3/03/2008

How SharePoint stores field names

In my one of my previous posts I've received a good comment from Mike that got me talking quite a lot about SharePoint List / Document Library Field Names. So it's better to dedicate a post to it. First I'll explain some exceptions and then show how to quickly get a sharepoint field name.

You can't change SharePoint field name

Once you create a field, you can't change the "SharePoint" name for it. Im using this sometimes when creating lists. I'll create a field called FirstName and then rename it to First Name. Like that I have no complications with spaces or any unstandard characters. So now (compared to previous post) I can filter with FilterField1=FirstName. 

 

Title field

No matter which list you create (except survey), there will always be one Title field no matter how we have it named. We can recognize this title field as the one that is linked to the item (with edit menu)

No matter what you rename this field to, this field will always be "SharePoint" named Title.

Field names for Out-of-the-box lists

Lists that are already included in the templates (like for example Contacts) have different "SharePoint" names than "Display" names. For example: In a Contacts list we can see a field called Fax Number, but "SharePoint" name for it is WorkFax. How to discover real names? Skip to the end of this post and read more.

Spaces and special characters in field names

Spaces in field names get converted to _x0020_. 0020 represents the Unicode character code. If you'd like to know any other, I've found this very good web character convertion tool. Just enter character into Characters field and you'll find the code in Hexadecimal code points but make it a 4 digit number (for example 20 for space should be 0020).

When using those special characters in URL, the underscore (_) gets converted to %5F

So how the heck to know SharePoint field names?

You COULD mess around with all the specialities and translations and conversions that I've mentioned untill now, but there's an easier way:(two actually):

1. Sort the List / Document Library and check in URL for SortField parameter value.
 


2. Go to List / Document Library Settings, click on the name of the column to modify it and in URL find the last parameter value
 

 

And ofcourse if you need to use the field name in other places than URL (like in SharePoint designer), don't forget to convert %5F to underscore.

P.S. - Yes, I know there is also a way to see SharePoint Field Names in SharePoint Designer (mouseover a field name in Data Source Details), but in this post I wanted to focus on work without it.

Oznake ponudnika Technorati:

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

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.