Delphi Technology Solutions - development, websites, computers and networks

Development   |   Computers & Networks   |   Websites   |   Products & Services   |   Client Success   |   News

David's Ramblings on Development

SharePoint, InfoPath, .Net and more




Customizing the Content Query Web Part

Share |
clock August 27, 2009 11:51 by author David Lozzi

The content query web part is a beautiful web part, and it's a shame it's only available in MOSS. I would love to use it in WSS. Anyway, the web part will search the entire site collection, or specific sites as you specify, and return items for certain content types, or all, and/or meeting a filter criteria.

As you can imagine, a very useful tool to roll up data and lists from sites all into a central page or dashboard. The issue with this web part is customizing it! There are a few predefined layouts but nothing that is really helpful. Basically, the web part lists the title, as a link to the item, all of the return results. No other fields are included. If you're interested in adding more fields, it requires some customization.

Fortunatly, there are a few SharePoint gurus out there who were nice enough to share how to customize this web part. Their links are below. I recommend reading through both blogs, though they may be repetitive, they compliment each other very well. Then come back and check out my notes below for some more help.

http://paulgalvin.spaces.live.com/Blog/cns!1CC1EDB3DAA9B8AA!491.entry

http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx

Further reference from Microsoft

http://msdn.microsoft.com/en-us/library/aa981241(classic).aspx

A Few More Notes

The above references are great, they got me where I am. In my experience:

- I used U2U Caml Builder to get the internal name of the field. Specifically, I was rolling up InfoPath forms, and the internal name was a GUID. By using U2U I pulled the internal name out which was _x0033_11111fc_x002d_d892_x002d_4a7e_x002d_a9bc_x002d_d839ee8ef885.

- I think there might be a name length limitation in the ItemStyle.xsl. In my previous note about the GUID name, I had to use the DataColumnRenames property in the .webpart file to get the column to work. <property name="DataColumnRenames" type="string">_x0033_11111fc_x002d_d892_x002d_4a7e_x002d_a9bc_x002d_d839ee8ef885,OpenDate</property>. I can reference OpenDate in the ItemStyle.xsl file.

-Formatting the above date field is easy enough as well. Add xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" to the header of the stylesheet. Then format the date: <xsl:value-of select="ddwrt:FormatDateTime(string(@OpenDate),1033,'M/d/yyyy h:mm tt')" />.

 





Creating custom ASPX pages which look like SharePoint application pages

Share |
clock August 24, 2009 15:26 by author David Lozzi

This one had me for a while until I accidently came across it looking for something else. My big issue was that the SharePoint pages were all laid out quite nicely, and pretty. Title and description on the left and the controls on the right in that neat blue. I recreated this layout manually: table, row, cell, span for the title, span for the description, next cell, class for the blue background, span for the label, user control, next row... and so on.

There are lovely user controls available: InputFormSection and InputFormControl. Using these user controls, these neat SharePoint formatted pages are a whiz to make! Instead of me reinventing the wheel, check out http://karinebosch.wordpress.com/sharepoint-controls/inputformsectionascx-control/ for a more details. Well worth it!





You can now comment on my posts

Share |
clock August 20, 2009 16:27 by author David Lozzi

I recently upgraded my blog to BlogEngine.Net and since then the comments stopped working. Seeing as I'm more busy than Obama right now, I never really stopped to properly troubleshoot it. Recently I took up the challenge and thanks to someone else having the same issue, my blog is now fixed and users can add comments to my posts. So please, comment away!

If you're looking for the solution for your own blog, see http://blogengine.codeplex.com/Thread/View.aspx?ThreadId=59277.





How to setup a page to autorefresh

Share |
clock August 17, 2009 11:02 by author David Lozzi

There has been a few requests from our customers to setup certain pages to autorefresh after a certain amount of time. These pages are usually views of a list, or the home page. I found a rather simple script to throw on the page which will reload the page for you. Copy the script below and paste it into a Content Editor Web Part by clicking the Source Editor button. Optionally you could use SharePoint Designer and add it to the page directly. Change the 30 in setReloadTime at the end to the desired refresh time in seconds.

<script type="text/javascript" language="javascript">
var reloadTimer = null;
var sURL = unescape(window.location.pathname);
function setReloadTime(secs)
{
 if (arguments.length == 1)  
 {
  if (reloadTimer) clearTimeout(reloadTimer);      
  reloadTimer = setTimeout("setReloadTime()", Math.ceil(parseFloat(secs)*1000));  
 }   else  
 {
  reloadTimer = null;    
  location.reload(true);    
  window.location.replace( sURL );  
 }
}
setReloadTime(30);
</script>

Enjoy!




RSSRSS Subscribe

About David Lozzi

I love what I do. I'm not the sketchy type that hides in his basement coding all day. I have a beautiful wife and two great children. I've spent my last 10 years plus in the technology arena. more...

Login