SharePoint 2020

The Vision for a Future of Clarity

Record Search Results Queries to a List using a Hit Counter

This is how I am using a Search Results page to record individual Users Search Queries in a list.  Each Search Query is displayed as how the user typed them in.

What I’ll explain is how we can grab the URL from the Search Results and strip out the unnecessary code to display only the User’s Search Query.

For Example

This Search Result URL:

?k=pdf&cs=This%20Site&u=https%3A%2F%2Fwww%2Enothingbutsharepoint%2Ecom&r=fileextension%3D"ascx"%20fileextension%3D"asp"%20fileextension%3D"aspx"%20fileextension%3D"htm"%20fileextension%3D"html"%20fileextension%3D"jhtml"%20fileextension%3D"js"%20fileextension%3D"mht"%20fileextension%3D"mhtml"%20fileextension%3D"mspx"%20fileextension%3D"php"

Will be converted to display only what the user has typed in the Search Box, which in this example, is: “pdf“.

Each time a user types in a Search, their query is recorded with their name, date and keywords typed.

Firstly, you need to install and configure the “Hit-Counter and Star-rating for SharePoint” from Alexander’s SharePoint JavaScripts site.

Once you have this configured it and you can see the users data added to the  HitCounter List , we can now modify the HitCounterAndStarRatingForSharePoint.js file to include the Users keywords entered.

1: First create a new column within the HitCounter list call it UserKeywords.  Add this column to your default view.

2: Edit the HitCounterAndStarRatingForSharePoint.js  and scroll down to about line 218:  //Add item.  Within that block of code you will see the column variables, make a new line under ReferringURL:refURL, and type in the new column name which is attached to the variable as such:

UserKeywords:searchQuery,

3:  Then under the following code at about Line: 152

// Get url and referrer
refURL = document.referrer;

Add the following lines of code:

searchURL = window.location.search;                               //returns string ?k=Users%20Search%20String
  modURL = searchURL.substring(3);                                   //removes characters ?k= from string
  decodedURL = decodeURIComponent(modURL);       //decode URL to translate encoded characters from string
  searchQuery = decodedURL.split('&')[0];                         //removes characters all after &

Each line I’ve added a comment that describes what each line does.  I don’t know how to write code in Javascript, so I had to Google Search each line to work out how to accomplish each Javascript function.

4:  Now you can test the Search Results page by entering in a Search Query and then checking the HitCounter List.

The UserKeywords column will now display the Search Keywords exactly how they are typed by the user.

Any questions, please comment below, thanks for reading.

Advertisements

July 1, 2013 Posted by | SharePoint 2010, SharePoint Designer 2010, SharePoint Javascript | , , | Leave a comment

Open all PDF files in Maximum Dialog Box

This code grabs any PDF file on the page and rather have them opening in the same window or a new window, they open conveniently in a SharePoint modal pop up dialog window.

All you need to do is:

1: Place the code below into a TXT or HTML file,

2: Upload it to a Document Library

3: Your could edit the file and change the path of JQuery to a local copy of JQuery1.9.1.min.js if required.

4: You could either reference the file path in a Content Editor Web Part.  eg: \sharepointserver\sites\sitecollection\subsite\scripts\pdfmaxdialogcode.html

or add the code to your Master Page in a .JS file . (Need help with this, post a comment below)

5: Open up a page where PDF files are located and test it out.

Fullscreen SharePoint Dialog

To see a preview of the result, refer to my previous post: https://sharepoint2020.wordpress.com/2013/02/15/how-to-open-a-pop-up-dialog-maximized-fullscreen/

This script was created by Alexander Bautz from http://spjsblog.com/

His post is located here: http://spjsblog.com/2013/05/31/open-pdf-files-in-a-maximized-dialog/

For redundancy, I’ll post the code here as well.

* After you Paste the code, you will need to remove the < code > < / code > tags from the script below, it’s the only way I can paste the code in WordPress without the Object tags being stripped out.
<!-- Put this code below the list view web part -->
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$("a[href$='.pdf']").each(function(){
$(this).removeAttr("onclick").attr("href","javascript:openPDFinDlg(\""+this.href+"\")");
});
function openPDFinDlg(href){
var o;
$("body").append("<div id='pdfTemp' style='min-height:600px;min-width:800px;height:100%;overflow:hidden'><<code>object</code> data='"+href+"' width='100%' height='100%' type='application/pdf' ></<code>object</code>></div>");
o = {};
o.html = $("#pdfTemp")[0];
o.showMaximized = true;
o.title = href.substring(href.lastIndexOf("/")+1);
o.dialogReturnValueCallback = openPDFinDlgCallback;
SP.UI.ModalDialog.showModalDialog(o);
}

function openPDFinDlgCallback(){
// do something here when the dialog closes
}
// ]]></script>

To enhance the display of PDF files to your site vistors

When dealing with PDF files, you can also add parameters from Adobe’s PDF Open Parameters documentation to the +href+ variable to present the PDF to your users.

Some examples of Adobe PDF Open Parameters:

The following table lists and describes the available PDF open parameters. Italics indicate user-specified variables.

page=pagenum
Specifies a numbered page in the document, using an integer value. The document’s first page has a pagenum value of 1.
zoom=scale
zoom=scale,left,top
view=Fit
view=FitH
view=FitH,top
view=FitV
view=FitV,left
view=FitB
view=FitBH
view=FitBH,top
view=FitBV
view=FitBV,left

Use the page command before this command.
pagemode=bookmarks
pagemode=thumbs
pagemode=none (default)
Displays bookmarks or thumbnails.
scrollbar=1|0
Turns scrollbars on or off.
toolbar=1|0
Turns the toolbar on or off.
statusbar=1|0
Turns the status bar on or off.
messages=1|0
Turns the document message bar on or off.
navpanes=1|0
Turns the navigation panes and tabs on or off.

for example: Within line 11, you can change this portion:

 data='"+href+"' width='100%' height='100%' type='application/pdf' 

to this

 data='"+href+"#page=1&view=fitV&pagemode=thumbs' width='100%' height='100%' type='application/pdf' 

For further documentation on Adobe Open Parameters see this link:

http://partners.adobe.com/public/developer/en/acrobat/PDFOpenParameters.pdf

* Possible issues: If the PDF link is located outside of your SharePoint server, the dialog window will display but the PDF may not.

Hope the code is useful for your site, thanks for reading.

June 3, 2013 Posted by | SharePoint 2010, SharePoint Designer 2010 | , , | Leave a comment

Reply to Discussion: Send Email to Item Owner using Workflow

After a few Google Searches, I finally found how to Send an Email, using SharePoint 2010 Designer Workflow, to the Original Creator of a Discussion Item when someone posts a reply to the discussion item.

Here is the original URL I used for the instructions: http://answers.flyppdevportal.com/categories/sharepoint2010/sharepoint2010customization.aspx?ID=03d57a50-17d6-4013-bb58-b816d97f63ec

“I learned that discussions have two different content types, Discussion for a new topic posted and Message for a reply to that topic.

The ID for the original discussion (topic) post is the column “ID” on that item. But the reply messages store this same number in the “Parent Folder ID” column.

So, I created a workflow with one condition, that the content type is Message. When the condition is met (only by replies), I send an email with the To field populated by: “Workflow Lookup for a User”, with the data source as the Current List, the Field from source as Created by and the Return field as Email Address.

Under Find the List Item, the column is ID and the Value is Current Item:Parent Folder ID. Then fill in the body of the email with whatever data you need.”

SP2010WorkflowDiscussionReply

Note:  Condition – “Current Item Content Type equals Message  (You’ll have to type in the word “Message”)

For the Action, just follow the picture that shows the correct way of determining the Originator of the Discussion Item.

For the Body, you could add a direct URL to the Discussion List Item from the following Blog Page: http://geekswithblogs.net/bjackett/archive/2011/02/18/sharepoint-designer-2010-email-link-to-item.aspx

Ask if anything is unclear. Thanks for reading.

April 17, 2013 Posted by | SharePoint 2010, SharePoint Designer 2010 | , | 8 Comments

Using Javascript URL in Calculated Columns

If you’re looking at using Javascript in a calculated column to call a URL, here’s a method that’s quick and simple to apply.

I found that when I attempted to run this inside a calculated column, the javascript url path removes the ” ” and therefore won’t run.

HTML Example of URL

<a onclick='javascript:openDialog("/server/site/CSSdocument.pdf");javascript:return false;' href="#" target=_self>

<img src="/server/site/CSS_Page_001.jpg" alt="" ></a>

So you could run the html inside a html file linked to the Content Editor Web Part first to make sure your Javascript works on the page, then add the Custom List with the calculated column below.

Instructions

First, create two ‘single line of text’ columns, each containing the following text as default value

jscript1

onclick='javascript:openDialog("

jscript2

");javascript:return false;'

Then, I have two versions of syntax you can use. Make sure you change “The data type returned from this formula is:” to Number (1, 1.0, 100)  This will convert your column to html.

Calculated Column Version 1

="<a "&jscript1&""&FileName&""&jscript2&" href='#' title='Title' target='_self'><img src='"&Thumbnail&"' alt=''></a>"

Calculated Column Version 2

=CONCATENATE("<DIV><a ",jscript1,"",FileName,"",jscript2," href='#' title='book' target='_self'><img src='",Thumbnail,"' alt=''></a></DIV>")

So from the examples above, each “jscript” column will be replaced with it’s code and which will use the “FileName” column as it’s URL.

It’s not as Dynamic as I would like, so this would suit a Site Owner who familiar with Javascript.

Any questions if it doesn’t work and would like assistance, please comment below.

February 20, 2013 Posted by | SharePoint 2010 | , | 6 Comments

How to Open a Pop-up Dialog Maximized Fullscreen

This is a great way to open links on your page without using Browser tabs or “Open in New Window” options.

This feature enables a specified link, when clicked to open in a dialog window with one extra feature, it opens in Maximized View to the exact dimensions of the users monitor.

I find this method is more user friendly, great for hiding the URL of the dialog content and perfect for showing PDF files while still keeping the user on your site.

Fullscreen SharePoint Dialog

First test this code in a html page and attach it as a Content Editor Web Part first, just to make sure everything is working.

<style type="text/css" >
#wrapper {
 width: 960px;
 margin: auto;
}
html.ms-dialog #wrapper {
 width: 100%;
}
</style>

<script type="text/javascript" >
function openDialog(strPageURL) {
var options = {
url: strPageURL,
showMaximized: true,
width: 800,
height: 500,
title: "Title of Dialog" };
SP.UI.ModalDialog.showModalDialog(options);
}
</script>

Once this code is pasted in use the following with your hyper link:

<a onclick='javascript:openDialog("/server/teamsite/document.pdf");javascript:return false;' href="#" target=_self> Click to Open</a>  

So on each hyper-link you just add this extra code to your URL for it to open in a maximized dialog window.

Please let me know if the code helps you in your SharePoint Enviroment or if you have any questions, just comment below.

* I’ve tried to find the site where I first obtained this code to give credit but cannot find which site I gathered most of the code from.

February 15, 2013 Posted by | SharePoint 2010, SharePoint Designer 2010 | , , | 1 Comment

Display PDF Thumbnail Preview on Hover in Search Results Web Part

This solution, provides an easy way to display a thumbnail view of a PDF file in SharePoint 2010 Search Results.

The idea for this useful feature came from here: http://cssglobe.com/easiest-tooltip-and-image-preview-using-jquery/ using  example 3, when you mouse over the link a pop-up thumbnail of a jpg is displayed.

So with a combination of a PDF in an iframe such as my previous article, a slight modification of the Javascript code (main.js) and some add-on code in the xslt of the search results web part, we achieve a thumbnail preview of all PDF file Search Results.

PDF Preview in Search Results

Steps to add this feature:

1: Download the Word doc below, PDF thumbnail script.docx, copy the contents to a new file and call it “main.js”, upload it to your script library. Because WordPress strips out iframe tags, this is the easiest option.

PDF thumbnail script .docx

2: Place the following into a .html file and upload it to your script library.  Don’t forget to rename the file paths to match your file locations.

<script src="/server/site/scripts/jquery.js" type="text/javascript" ></script>
<script src="/server/site/scripts/main.js" type="text/javascript"></script>
<style>
#screenshot{
position:absolute;
border:1px solid #ccc;
background:#333;
padding:5px;
display:none;
color:#fff;
}
</style>

3:  Add the following xslt to your Core Search Results web part

After this section:

<xsl:choose>
<xsl:when test=”hithighlightedproperties/HHUrl[. != ”]”>
<xsl:call-template name=”HitHighlighting”>
<xsl:with-param name=”hh” select=”hithighlightedproperties/HHUrl” />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select=”url”/>
</xsl:otherwise>
</xsl:choose>


<!-- Add PDF Preview in frame link to Search Result -->

<xsl:if test="(contains($url,'.pdf'))">
<a href="{$url}" >
<img border="0" src="/_layouts/images/MAGNIFY.GIF" alt="" style="padding-right: 5px; padding-left: 5px; vertical-align:bottom" />
 </a>
</xsl:if>

</span>

So each Search Result, which is a PDF file, will display a small magnifying glass and when the user hovers their mouse over the image, the javascript opens a small iframe window, which displays the PDF file. So no images are being created, no conversion is actually occurring.

One down-side point, the user must have Adobe reader installed to view the PDF files.

Thanks for reading, any questions, please comment.

October 23, 2012 Posted by | SharePoint 2010 | , | 18 Comments

SharePoint 2010 Content Anything Slider with Captions

This post is a follow on from the following Post from Hasanga Abeyaratne posted on NothingbutSharePoint.com

https://www.nothingbutsharepoint.com/sites/eusp/Pages/Building-a-fully-featured-jQuery-content-slider-for-SharePoint-2010.aspx

Basically, the Article above describes how to use items from a SharePoint list to generate a Content Slider so a user can click through each item.

To see a Demo of Anything Slider and to download the files http://css-tricks.com/examples/AnythingSlider

This is how I used the following code to get the Anything Slider Captions working with the above post and to have each Caption display the data from the Title field.

Below is the amended code required that I used to get this working.


<!-- jQuery --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
 <script src="/Server/scripts/ContentSlider/js/jquery.easing.1.2.js"></script>

<link href="/Server/scripts/ContentSlider/anythingslider.css" rel="stylesheet" >
 <script src="/Server/scripts/ContentSlider/jquery.anythingslider.js"></script>

<!-- Anything Slider optional plugins -->

<link rel="stylesheet" type="text/css" href="/Server/scripts/ContentSlider/slidercaptions.css" >
 <!-- <script type="text/javascript" src="/Server/scripts/ContentSlider/slidercaptions.js"></script>-->

<style>
 #slider1 {
width: 220px;
 height: 220px;
 list-style: none;
 }
 </style>
 <script type="text/javascript">
 $(document).ready(function() {
 var soapEnv = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
 <soapenv:Body> \
 <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
 <listName>AppReviews</listName> \
 <viewFields> \
 <ViewFields> \
 <FieldRef Name='Title' /> \
 <FieldRef Name='body' /> \
 </ViewFields> \
 </viewFields> \
 </GetListItems> \
 </soapenv:Body> \
 </soapenv:Envelope>";

$.ajax({
 url: "/Server/_vti_bin/lists.asmx",
 type: "POST",
 dataType: "xml",
 data: soapEnv,
 complete: renderSlides1,
 contentType: "text/xml; charset=\"utf-8\""
 });
 });

function renderSlides1(xData, status)
 {
 $(xData.responseXML).find("z\\:row").each(function() {
 var liHtml = "<li>" + $(this).attr("ows_body") + "<div class='caption-bottom'>" + $(this).attr("ows_Title") + "</div></li>";
 $("#slider1").append(liHtml);
 });

$(function(){
 $('#slider1') .anythingSlider()
 /* this code will make the caption appear when you hover over the panel
 remove the extra statements if you don't have captions in that location */
 .find('.panel')
 .find('div[class*=caption]').css({ position: 'absolute' }).end()
 .hover(function(){ showCaptions( $(this) ) }, function(){ hideCaptions( $(this) ); });

showCaptions = function(el){
 var $this = el;

if ($this.find('.caption-bottom').length) {
 $this.find('.caption-bottom')
 .show()
 .animate({ bottom: 0, opacity: 1 }, 250);
 }
 };
 hideCaptions = function(el){
 var $this = el;

if ($this.find('.caption-bottom').length) {
 $this.find('.caption-bottom')
 .stop()
 .animate({ bottom: -50, opacity: 0 }, 200, function(){
 $this.find('.caption-bottom').hide(); });
 }
 };

// hide all captions initially
 hideCaptions( $('#slider1 .panel') );
 });

}
 </script>
 <ul id="slider1"></ul>

* Note I have altered the original code to use id=Slider1, so within”slidercaptions.css” make sure you change Slider3 to Slider1.

Ask if anything is unclear. Thanks for reading.

October 7, 2012 Posted by | SharePoint 2010 | , , , | 1 Comment

jQuery Masonry for SharePoint 2010

This slideshow requires JavaScript.

jQuery Masonry http://masonry.desandro.com/  is a page layout feature involving the use of Divs, CSS and jQuery and I thought that would look great for web parts on a SharePoint page.  So using my SharePoint design/hacking skills, I created a Page Layout to work with jQuery Masonry.

No need to position web parts according to the default templates provided out-of-the-box, just add your web parts to the individual web part zones and let the users browser position them dynamically.

I find positioning web parts on a page tedious and time-consuming, trying to fit them in a 1024×768 area without scrolling horizontally can be frustrating, so when I stumbled on jQuery Masonry, I had to get this working in my environment.

I’ve adjusted jQuery Masonry to function with Web Part Zones on a SharePoint 2010 Publishing Page Layout. (code below).  All you need to do is place the most relevant or important web parts at the top of the page and the users browser would do the rest.

1: Instructions to add jQuery Masonry to your SharePoint environment:

2: Download jQuery Masonry files from link above

3: Open SharePoint Designer 2010

4: Copy Masonry Files to a Document Library, ie: scripts

5: Create new Page Layout at the top-level site collection.

6: Copy this code to a text editor and update the Masonry file paths.

7: Paste this code after this line: <asp:Content ContentPlaceholderID=”PlaceHolderMain” runat=”server”>

<WebPartPages:SPProxyWebPartManager runat="server" id="spproxywebpartmanager"></WebPartPages:SPProxyWebPartManager>

<!--[if lte IE 7]>
<link rel="stylesheet" type="text/css" href="../../scripts/masonry-site/css/ie7.css" />
<![endif]-->

 <style type="text/css">

.col1 { width: auto; }

.box {
 margin: 2px;
 padding: 2px;
 background: #D8D5D2;
 float: left;
 -webkit-border-radius: 5px;
 -moz-border-radius: 5px;
 border-radius: 5px;
}

 .clearfix { zoom: 1; }
 </style>

 <div id="container" class="clearfix">

<div class="box col1">

 <WebPartPages:WebPartZone id="g_A08B0D214A4D4D2AAA747A4FC19941FB" runat="server" title="Zone 1"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_DC055C5704EF427DA2E38F851900937B" runat="server" title="Zone 2"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_F7B0518D8025480F931833EEFCA92129" runat="server" title="Zone 3"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_7BCF356FE81A427BB4EDC8EB36FCB10F" runat="server" title="Zone 4"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_F379EB375FC143F292F52CD1393E2544" runat="server" title="Zone 5"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_94E95467DCA3410381D64A184F3A5716" runat="server" title="Zone 6"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_0C39484DF210480884A8ECD0828AD1C5" runat="server" title="Zone 7"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_90C8F765302B4D45942E22B8D90E7B77" runat="server" title="Zone 9"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_EBBDA9C3986C4388875859746F01C1E7" runat="server" title="Zone 10"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_4535738D283D4533AB249BFF19FFB200" runat="server" title="Zone 8"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_6A1674E0E7894655A6C92E84D1747A7D" runat="server" title="Zone 11"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_F1A07AFC0DBD466889A24252A531C7D3" runat="server" title="Zone 12"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_E48F91568389441083A17C4BA841CA39" runat="server" title="Zone 13"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

<WebPartPages:WebPartZone id="g_956FE13F1AA04B748DC75A4192BBFC96" runat="server" title="Zone 14"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

</div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_2AB70C79E55A4354976FE591C9D356BA" runat="server" title="Zone 15"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

<div class="box col1">

 <WebPartPages:WebPartZone id="g_EF783A5A11AA456D807BB9DD5F1E2B12" runat="server" title="Zone 16"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone>

 </div>

</div> <!-- #container -->

<script src="/scripts/masonry-site/js/jquery-1.7.1.min.js"></script>
<script src="/scripts/masonry-site/jquery.masonry.min.js"></script>
<script>
 $(function(){

 $('#container').masonry({
 itemSelector: '.box',
 columnWidth: 10,
 isAnimated: true
 });

 });
</script>

8: Save, check in, publish.

9: Create a new Publishing Page

Publishing Page Layout
For IE7 Users add the follwing CSS, because of the way IE7 uses width: 100% inside Width: Auto, the web part zones will expand to 100% of the page.

.s4-ca table {
 width: auto; !important
}
.box {
 margin: 0px;
 padding: 0px;
}
/* toolpane */
.ms-ToolPaneOuter {
 position: relative;
}

This is how I achieved jQuery Masonry for SharePoint 2010 Publishing Page Layout.
Any questions or ideas for improvement, please comment.

September 2, 2012 Posted by | SharePoint 2010, SharePoint Designer 2010 | , | Leave a comment

Create PDF thumbnail view in column using iframes

This is how I created a thumbnail view of PDF files in a Document Library.

Using a Document Library to store PDF Files. Call it “Uploads”

1: Create workflow using SharePoint Designer to copy Name column to Title column.  This will allow us to use the Title column in a Calculated Column.  This Blog post describes the process: http://www.knowledgegroup.no/blogg/post/2012/05/13/Add-filename-in-title-field-using-workflow.aspx

2: Add a Calculated Column to the document library, call it “Preview”

Copy this formula:

=CONCATENATE("<DIV><iframe width='200px', height='200px', scrolling='no', src='http://server/uploads/",Title,".pdf#page=1&toolbar=0&scrollbar=0&navpanes=0&statusbar=0'></iframe></DIV>")

* change http address to your SharePoint server name and change to location of PDF files.  

3:  Add a Content Editor Web Part to the Document Libary view and copy the link to Christophe’s Text to HTML code:

Or use the Calc column, Number option work-around.

<script type="text/javascript">// <![CDATA[
//
// Text to HTML
// Feedback and questions: Christophe@PathToSharePoint.com
//
var theTDs = document.getElementsByTagName("TD");
var i=0;
var TDContent = " ";
while (i < theTDs.length)
{
try
{
TDContent = theTDs[i].innerText || theTDs[i].textContent;
if ((TDContent.indexOf("<DIV") == 0) && (TDContent.indexOf("</DIV>

") >= 0)) {
theTDs[i].innerHTML = TDContent;
}
}
catch(err){}
i=i+1;
}
// ]]></script>

That’s it, upload your pdf files, test and adjust.

One down-side is the page does load a little slow as it’s trying to load multiple pdf files.

I’ve tested it on IE9 and IE7 using different hardware and the page loads fine for my purposes.

If someone knows of a solution that can be used to convert the first page to a picture thumbnail that would be better for performance, or if you have any questions, please post in the comments section below.

Thanks for reading.

Request from to Ben, here is the calculated column as it should appear.

*Please note, you must have the filename of the PDF in the TITLE Column.
* Using Number as the data type, you won’t require Christophe’s code snippet above.

 

PDFthumbcalc_column

August 10, 2012 Posted by | SharePoint 2010, SharePoint Designer 2010 | , , , , | 20 Comments

Add a “Create Alert” dialog link in a Content Editor Web Part

This is the code I have used in a Content Editor Web Part to display a “Create Alert” link.  It’s probably not the preferred method but it’s what I used to get it working in my environment.

Update: I utilized some of the instructions below from Mike Smith’s Tech Training Notes: http://techtrainingnotes.blogspot.com.au/2011/10/sharepoint-create-alert-from-anywhere.html

The link pops up in a dialog window as if the user selects the same option from the Ribbon.

This is useful if you are hiding the Ribbon from users with Read access or if you are displaying multiple Lists within a Web Part Page.

1: First, from the Alert Me option in the Ribbon and select Manage my Alerts.  Click Add Alert to bring up the lists and libraries of the site.

2:  Select the list you would like to use for the “Create Alert” link and click Next.

3: When the next page loads, “Listname – New Alert”, copy the URL and paste it into a text editor.  The URL should look like this:

http://sharepointserver/_layouts/SubNew.aspx?List={A0E53466-4C68-4DFC-AD6A-42DF8FAD1541}&Source=%2F_layouts%2FMySubs.aspx 

4: Add the following to the end of the URL to display the dialog without the master page:  &isdlg=1

5: From here copy this URL X 2 into the following bit of code:

<A id=idHomePageNewItem onclick=’javascript:NewItem2(event, “http://sharepointserver/_layouts/SubNew.aspx?List={A0E53466-4C68-4DFC-AD6A-42DF8FAD1541}&Source=%2F_layouts%2FMySubs.aspx&isdlg=1“);javascript:return false;’href=”http://sharepointserver/_layouts/SubNew.aspx?List={A0E53466-4C68-4DFC-AD6A-42DF8FAD1541}&Source=%2F_layouts%2FMySubs.aspx&isdlg=1” target=_self><img alt=”Receive alerts in email” src=”../../_layouts/images/lg_ICMSG.gif” border=”0″ width=”20″ height=”20″> Subscribe to Announcement Alerts</a>
6: Copy the code into a text file, upload it to your SharePoint “scripts” folder, copy the link and paste into a Content Editor Web Part.

You should now see this:

When Clicked, a Dialog Popup will display the Create Alert window:

Thanks for reading, any questions, please comment below.

July 10, 2012 Posted by | SharePoint 2010 | , , , | 2 Comments