Tuesday, April 28, 2009

Separate XSL files for Content Query Webpart (CQWP)

Using the same ItemStyle.xsl for all the content query webparts in the site is a very bad thing to do, especially with the big sites.
But you can make an XSL file for each content query webpart and here is how to do:

  1. Edit the page you want to add the webpart in.
  2. Add a content query webpart.
  3. Export the webpart.
  4. Open the exported file.
  5. Search for “ItemXslLink”
  6. Update the line to:

    <property name="ItemXslLink" type="string">/Styles/XSL/MyCQWebpart.xsl</property>

  7. Update the property "ItemStyle" to the templete name ("UsefulLinks" in this example)
  8. Upload the XSL file (remember to update "CommonViewFields" as needed)
  9. The XSL file can be something like this to display a useful links (Title, Link):

    <xsl:stylesheet version="1.0" exclude-result-prefixes="x d xsl msxsl cmswrt" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
    <xsl:template name="UsefulLinks" match="Row[@Style='UsefulLinks']" mode="itemstyle">
    <xsl:param name="CurPos" />
    <xsl:variable name="TitleLenght" select="string-length(@Title)" />
    <xsl:variable name="RowLimit" select="40" />
    <xsl:variable name="LinkURL" select="substring-before(@Link,',')" />
    <xsl:variable name="LinkText" select="substring-after(@Link,',')" />
    <li>
    <a href="{$LinkURL}" target="_blank" title="{$LinkText}" class="newsTitle">
    <xsl:value-of select="$CurPos" /> - <xsl:value-of select="@Title" />
    </a>
    </li>
    </xsl:template>
    </xsl:stylesheet>

  10. Import the webpart and configure it to read from the right place, filtration and sorting order and so on.
  11. Go to the “ContentQueryMain.xsl” file and search for “OuterTemplate.CallItemTemplate”
  12. In <xsl:apply-templates select="." mode="itemstyle"> add <xsl:with-param name="CurPos" select="$CurPosition" /> and any other parameters you want to send to the itemstyle.
  13. You can also make your own ContentQueryMain XSL by updating the “MainXslLink” property in the webpart file, and the same for the header by updating the “HeaderXslLink” property.

Monday, April 27, 2009

Delete WorkItem from TFS database

To delete workitem added by mistake, you have to delete every thing related to it, so you can go to the TFS database and run the following

Declare @DeleteThisID int set @DeleteThisID = 10000

DELETE FROM [WorkItemLongTexts] WHERE ID = @DeleteThisID
DELETE FROM [WorkItemsAre] WHERE ID = @DeleteThisID
DELETE FROM [WorkItemsWere] WHERE ID = @DeleteThisID
DELETE FROM [WorkItemsLatest] WHERE ID = @DeleteThisID

Monday, April 20, 2009

Error 'Code-blocks are not allowed in this file'

http://www.hammendorp.net/post/Error-Code-blocks-are-not-allowed-in-this-file.aspx

Features included in Office SharePoint Server 2007

"Features are modular groups that provide a collection of functionality. Features are available depending on the license type of the Office SharePoint Server 2007 installation, and are activated at various levels of the logical structure of Office SharePoint Server 2007: farm level, Web application, site collection, and site level."

http://technet.microsoft.com/en-us/library/cc678862.aspx

This article contains information about Microsoft Office SharePoint Server 2007 features and the level at which you can activate them.

Sunday, April 12, 2009

SPListItem: Update(), SystemUpdate() and UpdateOverwriteVersion()

If you are working with MOSS APIs to create list items and updating them, you have the option to update the item by using Update(), SystemUpdate(), SystemUpdate(false) or UpdateOverwriteVersion() methods, but what is the difference between them?

Update()

  • will make a new version of the item
  • Update the modified time and modified by fields
  • If the item is published it will be pending again
UpdateOverwriteVersion()
  • No new version.
  • Updates the item without creating a new version of the item
  • Update the modified time and modified by fields
SystemUpdate()
  • Nothing will be changed in the item except the fields you want to change
  • No new version (You can pass false to the method just to enable generating a new version)
  • The events will be fired and the modifications will be logged, but no alerts will be sent, and you can disble the event firing before using the SystemUpdate then enable it again

SystemUpdate() is very useful if you want to modify something like the rating value after the item is published without reapproving it every time.


Saturday, April 11, 2009

كان يا ما كان

رسالة كتبتها لأودع فريق العمل اللذي عملت معه بشركة لينك ديف بمصر للعمل بفرع الشركة بالسعودية


كان يا ما كان


هل سمعتم عن إمارات الأبدان؟ ليست ببغداد ولا إيران! في كل حين وآن وأوان يُحكى عن إمارة في كان يا ما كان.. العقل لها حاكما ومُستشاره القلبُ بالانسان، الشعبُ عاش خلالها لبرهة من الزمان فترة رخاءٍ وامانٍ. وفي يوم من الأيام أصدر العقل حكماً قاسياً ليس فيه رأفة ولا إحسان، لم يُستشار المُستشار في الحكم حيث أنه أول من يدان، لم يرتكب القلب جُرما بل يُخشى منه على باقي الجسمان، العقل يخشى ان تثور عليه يدٌ او اذنٌ من الاذنان، أو قد تنقلب عليه قدميه أو يعارضه اللسان، كل هذا لأنه أخذ القرار وعلى البقية السمع والطاعة للسلطان. وفي ساعة المحاكمه (الآن) وقف العقلُ مُحاكماً لكنه يعلم ان مكانه مع البقية خلف القضبان، وبعد مرافعة القلب المُستشار والبلاغة في البيان، والتي ادت لهطول امطار غزيرة بمنطقة العينان وإثارة العواصف بمنطقة الرئتان. في الحال اُصدر الفرمان وقد تناقلته وسائل الاعلام.. بتوقيع اتفاق دبلوماسي مع باقي الامارات من الزملاء والاحباب والخلان، أن يترك بكل امارة ذكرى كسفير خير عبر الايام، و يَحِقُ للمتهمين زيارة السفراء كلما كان ذلك بالإمكان، لتجديد هعد وفاء وإخاء و سلام، وفي النهاية ختم الحكم بقوله: في هذا الزمان هذا ما كان يمكن ان يكون بالإمكان، فسلام.



Blessings of working on large real-world projects

Working on large real-world projects can offer numerous blessings and benefits, both professionally and personally. Here are some of the key...