Not that I am an advocate of the 'Bookmark' or 'Add to Favorites' type of links, but I had a challenge of creating a link that clients, using our Business Directory application, could use to point directly to their details page. Here is how I did it.
The challenge was to:
- Find a way to get the URL address of the XMod inline details page
- Link it as a bookmark that would work in most browsers including FireFox and Internet Explorer
The main hurdle was getting the routine to bookmark properly in FireFox. Most issues, with FireFox bookmarking, is the fact that the bookmark wants to add itself to the sidebar. After a few hours trying different scripts, I found that the one used below works on most browsers.
I discovered it at http://emanaton.com/coding/javascript/linkthispage.
I began by creating the following URL for my details page:
http://{XMOD_PortalAlias}/Resources/FindaVendor/tabid/
{XMOD_TabId}/xmmid/{XMOD_ModuleId}/xmid/<xmod:recordid/>/xmview/2/Default.aspx
Next, I added the following JavaScript to the top of the details page:
(Making sure it is placed above the final calling script)
<xmod:scriptblock scriptid="BookmarkScript" registeronce="true" blocktype="ClientScript">
<script type="text/javascript">
// http://emanaton.com/coding/javascript/linkthispage
function createBookmarkLink(url, title) {
try {
if (window.sidebar) { // Mozilla Firefox Bookmark
return window.sidebar.addPanel(title, url, "");
} else if( window.external ) { // IE Favorite
return window.external.AddFavorite( url, title);
} else if(window.opera && window.print) { // Opera Hotlist
return true;
}
} catch(err) {
// do nothing
}
alert('Could not create a bookmark on your client.\n\nTo return to ' + title + ' you must manually
create a bookmark to: \n' + url + '.');
}
function writeBookmarkLink(url, title) {
try {
if (window.sidebar) { // Mozilla Firefox Bookmark
return document.write('<a href="javascript:createBookmarkLink(\'' + url + '\', \'' + title + '\')");">
Create a Bookmark to <em>' + title + '</em></a>');
} else if (window.external) { // IE Favorite
return document.write('<a href="javascript:createBookmarkLink(\'' + url + '\', \'' + title + '\')");">
Add <em>' + title + '</em> to your Favorites</a>');
} else if (window.opera && window.print) { // Opera Hotlist
return document.write('<a rel="sidebar" href="' + url + '" title="' + title + '">
Create a Bookmark to <em>' + title + '</em></a>');
}
} catch(err) {
// do nothing
}
return document.write('To return to ' + title + ' create a bookmark to:
<a style="color: white;" href="' + url + '">' + url + '</a>');
}
</script>
</xmod:scriptblock>
An finally I created the Bookmark link:
<script>writeBookmarkLink(
'http://{XMOD_PortalAlias}/Resources/FindaVendor/tabid/{XMOD_TabId}/xmmid/{XMOD_ModuleId}
/xmid/<xmod:recordid/>/xmview/2/Default.aspx', '<xmod:field name="ListingTitle" />');</script>
<noscript>To return to <em><xmod:field name="ListingTitle" /></em> create a bookmark to:
<a href="http://{XMOD_PortalAlias}/Resources/FindaVendor/tabid/{XMOD_TabId}
/xmmid/{XMOD_ModuleId}/xmid/<xmod:recordid/>/xmview/2/Default.aspx">http://{XMOD_PortalAlias}/Resources/FindaVendor/tabid/{XMOD_TabId}
/xmmid/{XMOD_ModuleId}/xmid/<xmod:recordid/>/xmview/2/Default.aspx</a></noscript>
How to Bookmark an Inline XMod Details Page. You can see it in action at:
http://dnnprofessor.com/Resources/FindaVendor.aspx
Happy coding,
Buck