Ask a questionAsk a question
 

AnswerWeb part Title in Contentquerymain.xsl

  • Wednesday, June 18, 2008 7:30 PMprovma2020 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    I'm currently editing the Contentquerymain.xsl to modify the look of all my CQWPs and it looks really nice.  The only problem is I would like to get the web part title in the Contentquerymain.xsl.  I don't want to put the title in the normal web part header, because it will modify all web parts headers and I only want to modify the CQWPs ones.  So is there a way to get the web part Title in the Contententquerymain.xsl through a param or variable or something else?  If you can show me some code sample, it would be great.  Or maybe there's a way with the CSS files to modify the look of a web part title but only for a certain kind of web part (like CQWP).

     

    Thanks.

Answers

  • Tuesday, June 24, 2008 12:45 AMJerry Yu Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello,

    You can realize it through customize individual webpart. You can export some webpart you want to customize and then import it after modification.

    You can create your own version of the ContentQueryMain.xsl file that you can use for that specific web part.

    The first step is to make a copy of the ContentQueryMain.xsl file. You can do this with Microsoft SharePoint Designer 2007.

    1.     Open the site you wish to modify.

    2.     Browse to "/Style Library/XSL Style Sheets".

    3.     Make a copy of ContentQueryMain.xsl and rename it as you see fit.

    4.     Open the file and make any modifications that you see fit.

    Note: You may want to make a very minor change at first so you can discern the original ContentQueryMain.xsl file from your new copy of this file.

    Now that you have a working copy of the stylesheet, you'll have to reference it in your CQWP. Browse to the page that contains the web part you wish to customize, and then go into edit mode in order to edit that particular web part.

    Once in edit mode:

    1.     Click on the edit menu for the CQWP that you wish to customize

    2.     Click on Export…

    3.     You will be prompted to save a ".webpart" file somewhere on your local machine

    4.     Save the file and then open it up with SharePoint Designer

    There are a number of web part properties that you can modify here within SharePoint Designer. Scroll down the file and look for the line that begins with <property name="MainXslLink"… You will have to replace this line with the following code, replacing "MyCustomCQMain.xsl" with the name of your own file.

    <property name="MainXslLink" type="string">/Style Library/XSL Style Sheets/(your own file name).xsl</property>

    Now save your changes, then browse back to your website and (once again in edit mode):

    1.     Click on Add a Web Part.

    2.     Click on Advanced Web Part gallery and options (near the bottom-right of the pop-up window).

    3.     At the top of the Add Web Parts task pane, click on Browse and select Import.

    4.     Browse to your custom .webpart file.

    5.     Click on Upload.

    6.     Select a web part zone from the "Add to:" menu and then click on Import.

     

    Hope it can help you.

     Regards,

    Jerry

     

All Replies

  • Tuesday, June 24, 2008 12:45 AMJerry Yu Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello,

    You can realize it through customize individual webpart. You can export some webpart you want to customize and then import it after modification.

    You can create your own version of the ContentQueryMain.xsl file that you can use for that specific web part.

    The first step is to make a copy of the ContentQueryMain.xsl file. You can do this with Microsoft SharePoint Designer 2007.

    1.     Open the site you wish to modify.

    2.     Browse to "/Style Library/XSL Style Sheets".

    3.     Make a copy of ContentQueryMain.xsl and rename it as you see fit.

    4.     Open the file and make any modifications that you see fit.

    Note: You may want to make a very minor change at first so you can discern the original ContentQueryMain.xsl file from your new copy of this file.

    Now that you have a working copy of the stylesheet, you'll have to reference it in your CQWP. Browse to the page that contains the web part you wish to customize, and then go into edit mode in order to edit that particular web part.

    Once in edit mode:

    1.     Click on the edit menu for the CQWP that you wish to customize

    2.     Click on Export…

    3.     You will be prompted to save a ".webpart" file somewhere on your local machine

    4.     Save the file and then open it up with SharePoint Designer

    There are a number of web part properties that you can modify here within SharePoint Designer. Scroll down the file and look for the line that begins with <property name="MainXslLink"… You will have to replace this line with the following code, replacing "MyCustomCQMain.xsl" with the name of your own file.

    <property name="MainXslLink" type="string">/Style Library/XSL Style Sheets/(your own file name).xsl</property>

    Now save your changes, then browse back to your website and (once again in edit mode):

    1.     Click on Add a Web Part.

    2.     Click on Advanced Web Part gallery and options (near the bottom-right of the pop-up window).

    3.     At the top of the Add Web Parts task pane, click on Browse and select Import.

    4.     Browse to your custom .webpart file.

    5.     Click on Upload.

    6.     Select a web part zone from the "Add to:" menu and then click on Import.

     

    Hope it can help you.

     Regards,

    Jerry

     

  • Tuesday, October 07, 2008 6:53 PMTed A Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello:

    I'm running into the same scenario as the original poster, but am not seeing the answer in the "answer" posting.

    Specifically, how can one access the title of the web part from the xsl. The rendering of the web part title out of the box appears to be handled by the WebPart.RenderControl method. I would like to be able to customize the rendering of the web part title from the xsl if at all possible. This would involve getting the web part title into the XSL as a parameter.

    If you've successfully done this, can you provide insight as to how?

    Thanks,

    Ted
  • Thursday, March 19, 2009 11:10 PMRandy DrisgillMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Anyone find this answer: "Specifically, how can one access the title of the web part from the xsl"?

    I have tried to locate it without much luck.
    Randy Drisgill - MVP SharePoint Server
    SharePoint911 Branding and UI Services
    My Blog: http://blog.drisgill.com
    Wrox: Professional SharePoint 2007 Design
  • Wednesday, May 20, 2009 4:48 PMJoel Alexandre Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    has anyone found the answer?


  • Wednesday, May 20, 2009 6:10 PMIvan Sanders Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I believe there are two files associated with this ItemStyle.xsl and ContentQueryMain.xsl. However, Title and customization 
    is included in ItemStyle.xsl

    ItemStyle.xsl
    Contains templates that define how to display an item. These templates receive and process one row of data at a time, ensuring that the style and data in the item rows is consistent. You can retrieve data about a row by using the @Property directive.

     

    <xsl:variable name="DisplayTitle">
    <xsl:call-template name="OuterTemplate.GetTitle">
    <xsl:with-param name="Title" select="@Title"/>
    <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
    </xsl:call-template>
    </xsl:variable>

    Also, please follow best practices when modifying any of the XSL or XML stuff in SharePoint...

    References
    http://www.microsoft.com/belux/msdn/nl/community/columns/stevenvandecraen/contentquerywebpart.mspx
    http://msdn.microsoft.com/en-us/library/aa981241.aspx
    http://msdn.microsoft.com/en-us/library/bb447557.aspx


    -Ivan


    Ivan Sanders http://linkedin.com/in/iasanders http://dimension-si.com/blog
  • Wednesday, May 20, 2009 10:29 PMJoel Alexandre Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks Ivan for your reply, but what is needed is the web part title , not the items title.

        "Specifically, how can one access the title of the web part from the xsl"
  • Wednesday, May 20, 2009 10:36 PMIvan Sanders Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Cool, so what do you want to do to or with the WebPart Title.... Do you want it to be all WebPart Titles? Jusdt the Look and Feel?


    -Ivan
    Ivan Sanders http://linkedin.com/in/iasanders http://dimension-si.com/blog
  • Wednesday, May 20, 2009 10:42 PMJoel Alexandre Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I need to change the web part title layout of 1 (one!) web part. Changing the CSS would change all web part titles, so it's not an option.

    I thought the if i could get the Web Part title in the ContentQueryMain.xsl, i could output a custom "title" layout.

    Any ideas how?

    Thanks
  • Wednesday, May 20, 2009 10:46 PMRandy DrisgillMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    More importantly, is the string value for the WebPart title available to XSLT? Like if you wanted to display the Title in the body of the web part via XSL.
    Randy Drisgill - MVP SharePoint Server
    SharePoint911 Branding and UI Services
    My Blog: http://blog.drisgill.com
    Wrox: Professional SharePoint 2007 Design
  • Wednesday, May 20, 2009 10:54 PMJoel Alexandre Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    (...) is the string value for the WebPart title available to XSLT? (...)
    That's the problem -  I don't know. 

    Maybe my approach is wrong. Is it possible to change the look and feel of the title of a single webpart?

    -Joel
  • Wednesday, May 20, 2009 11:08 PMRandy DrisgillMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Well, you could kind of tackle it from different point of view by first making a custom page layout and then putting that web part into its own <div class="specialWebPartHolder"> and then using that class before the ootb ms one. That would only work for specific cases though. You may not be able to solve your issue that way.
    Randy Drisgill - MVP SharePoint Server
    SharePoint911 Branding and UI Services
    My Blog: http://blog.drisgill.com
    Wrox: Professional SharePoint 2007 Design
  • Wednesday, May 20, 2009 11:13 PMIvan Sanders Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Cool or the following

    The easiest way is not to use the WebPart Title since your only goibng to be using it on one Page

    One
    1. Set the Chrome Type to None:
    2. Add a CEWP directly Above the CQWP
    3. Create an image with the formatting that you want.
    4. Add the image  or Whatever HTML to the CEWP

    There are a lot of Internet facing Sites using SharePoint built this way

    Two
    1. Create a custom CSS
    2. Change the follwoing  class=ms-standardheader ms-WPTitle
    3. Apply the Alternate CSS to this one Page


    Three
    1. Randys idea above accept that you can create a DIV for the WebPart Zone to hold the WebPart

    Cheers,

    -Ivan

    Ivan Sanders http://linkedin.com/in/iasanders http://dimension-si.com/blog
  • Wednesday, May 20, 2009 11:13 PMJoel Alexandre Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    @Randy
    I thought of that too. But i only want the title to show if there are results in the CQWP. And that logic i can't put in a layout.

    @Ivan
    One: did that - the problem is that the CEWP is always there even if there are no results in the CQWP
    Two: although it is the feel and look of one WP in a page, that page has several  WPs. All WPs in that page would then have the alternative title look and feel which is not supposed to happen.
    Three: Same problem as One


    Just some wild guess. If i could group the CQWP items in only one group,  i could use the group title as the header.
    • Edited byJoel Alexandre Wednesday, May 20, 2009 11:32 PMAnswer to Ivan and a wild guess
    •  
  • Friday, June 26, 2009 10:51 PMJoel Alexandre Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I've solved a while back. Only today i've documented it: custom content query webpart header and footer
  • Friday, October 09, 2009 12:26 PMebergh Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi

    When i tried Jerrys example the webpart will not import.

    ----------------------- EDIT ----------------------------
    And the reason is that i did not see that the <property name="MainXslLink"> was allready inn the file.

    All hail jerry, he was totaly right :)
  • Friday, October 16, 2009 3:25 AMnareshveeragoni Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    HI guys

    did anyone find a way to get the "Webpart Title" using the XSLT in Content Query Webpart.

    I can get the PageUrl and Webpart Id using parameters
    <xsl:param name="PageUrl" />
    <xsl:param name="WebPartId" />

    but could not get any of the webpart properties, where I am specifically looking to get the "Web Part Title URL" and "Web part Title"
    as i have Links in the webpart Body that will link based on values in these two properties.

    please, please let me know if you have anywork around to get the webpart Title URL and WEbpart Title using XSl from any of the xsl files out there in sharepoint[contentquerymain.xsl, Itemstyle.xsl, Header.xsl]..

    Thank you.

    naresh
  • Wednesday, November 04, 2009 3:33 PMChris Pettigrew Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I will be doing this today via extending the CQWP to include the value set in the Webpart Properties and then intergrate that with the XSLT..

    Will post back when i have completed this to help you :)

    Chris
    Chris