Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SharePoint > SharePoint 2007 > BOOK: Professional SharePoint 2007 Design ISBN: 978-0-470-28580-0
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional SharePoint 2007 Design ISBN: 978-0-470-28580-0 Discuss the book Professional SharePoint 2007 Design by Jacob J. Sanford, Randy Drisgill, David Drinkwine, Coskun Cavusoglu; ISBN: 978-0-470-28580-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional SharePoint 2007 Design ISBN: 978-0-470-28580-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 17th, 2009, 06:10 PM
Registered User
 
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 10 - Creating custom item style (pp. 414-420)

Has anyone been successful in getting the body of the announcement to show up under latest news instead of just the title? I don't know what I'm missing.

I exported the webpart. I edited the
Code:
 <property name="CommonViewFields" type="string">Body, Note</property>
in the webpart file and uploaded it back up. I know it's the uploaded one I am using because it shows my settings before I edited the code (ie expires is set properly).

I found the ItemStyle.xsl file and made it look like the gray section of the book (though it was confusing due to the last paragraph on page 416 not agreeing exactly with what is shown in the gray section page 417). When I save that and check it back in, the NewsItemWithBody is now showing up as an option for Item Style and I choose it. But once I apply and save, the link still shows only the title.

There are no examples in the code files that come with the book to compare with so I'm stuck on why this is not working as expected. I'd like to understand what I've done wrong here before moving onto the Data View section of the book!

Thanks,

Linda
Reply With Quote
  #2 (permalink)  
Old April 3rd, 2009, 02:39 AM
coskunc's Avatar
Wrox Author
 
Join Date: Feb 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default CQWP - Custom Design Steps

Exporting the webpart and adding the code(shown below) is the first step in showing the body. But there a couple other steps you must follow before you see the content.
Code:
 <property name="CommonViewFields" type="string">Body, Note</property>
Your next step is to open the ItemStyle.xml file and add the code that starts in p417 and ends in p418 to the bottom of ItemStyle.xml.Once you save that you should be good to go.

I'm attaching an example xsl file you can look at for your reference.



--------------
More information
--------------
The below code is displays body after it cleans the markup around it.


Code:
 <xsl:template name="NewsItemWithBody" match="*" mode="itemstyle">
        <xsl:variable name="SafeLinkUrl">
            <xsl:call-template name="OuterTemplate.GetSafeLink">
                <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="SafeImageUrl">
            <xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
                <xsl:with-param name="UrlColumnName" select="'ImageUrl'"/>
            </xsl:call-template>
        </xsl:variable>
        <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>
        <xsl:variable name="LinkTarget">
            <xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
        </xsl:variable>
        <div id="linkitem" class="item">
            <xsl:if test="string-length($SafeImageUrl) != 0">
                <div class="image-area-left"> 
                    <a href="{$SafeLinkUrl}" target="{$LinkTarget}">
                        <img class="image" src="{$SafeImageUrl}" alt="{@ImageUrlAltText}" />
                    </a>
                </div>
            </xsl:if>
            <div class="link-item">
             <xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>    
                <a href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}">
                    <xsl:value-of select="$DisplayTitle"/>
                </a>
                 <xsl:variable name="bodyContent">                     
                 <xsl:call-template name="removeMarkup">                           
                 <xsl:with-param name="string" select="@Body"/>                     
                 </xsl:call-template>              
                 </xsl:variable>                
                 <div class="description">             
                  <xsl:value-of select="$bodyContent"/>             
                   </div>          
                     </div>
        </div>
    </xsl:template>
And based on page 417 you need to add the remove markup code (shown below) that is referenced from
http://blogs.msdn.com/ecm/archive/20...-web-part.aspx



Code:
    <xsl:template name="removeMarkup">                       
     <xsl:param name="string" />                       
  <xsl:choose>                       
   <xsl:when test="contains($string, '&lt;')">                              
       <xsl:variable name="nextString">                                     
        <xsl:call-template name="removeMarkup">                                     
         <xsl:with-param name="string" select="substring-after($string, '&gt;')" />                                     
        </xsl:call-template>                              
       </xsl:variable>                              
       <xsl:value-of select="concat(substring-before($string, '&lt;'), $nextString)" />                       
      </xsl:when>                       
      <xsl:otherwise>                              
       <xsl:value-of select="$string" />                       
      </xsl:otherwise>                     
     </xsl:choose>          
 </xsl:template>
Attached Files
File Type: zip ItemStyle.zip (1.6 KB, 7 views)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 4, pp 130-131 luciano991 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 August 15th, 2006 12:23 PM
Chapter 4 pp. 118-119 luciano991 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 August 13th, 2006 02:56 PM
chapter 2 ; pp 59 - 62 ritter BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 4 April 28th, 2004 02:30 AM
Chapter 13 - Creating Your Own Custom Controls msjolin BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 2 February 16th, 2004 09:01 PM



All times are GMT -4. The time now is 03:14 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.