none
URL token ~sitecollection within Elements.xml file <ContentLink>/SITENAME/Lists/…

    Question

  • Hi All

    I am having a problem linking a Content Editor WebPart to a text file using a feature. The Content Editor WebPart and the txt file will be located on the same site, and the feature will be activated on any subsite. When I open the Content Editor WebPart page it is blank. I think I know what the problem is, but I do not know how to correct it. Instead of the Content Editor WebPart txt file url linking to/SUBSITENAME/Lists/JavaScript/TextFiles/Alert Box.txtit is linking to/Lists/JavaScript/TextFiles/Alert Box.txtand therefore cannot find the text file.


    The code within the Elements.xml file that I think is causing this problem is:

    <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">/Lists/JavaScript/TextFiles/Alert Box.txt </ContentLink>

    **************Code Snippet********************

    <?xmlversion="1.0"encoding="utf-8"?>

    <Elementsxmlns="http://schemas.microsoft.com/sharepoint/">

    <ModuleName="ContentEditorJSWebParts_Module"Url="Lists/JavaScript">

    <!--JavaScript Content Editor Text File Examples-->

    <FilePath="ContentEditorJSWebParts_Module\default.aspx"

    Url="JS Alert Box.aspx"

    Type="GhostableInLibrary">

    <AllUsersWebPartWebPartOrder="1"

    WebPartZoneID="Left"

    ID="JSAlertBox">

    <![CDATA[

    <?xml version="1.0" encoding="utf-8"?>

    <WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">

    <Title>Content Editor</Title>

    <FrameType>Default</FrameType>

    <Description>Allows authors to enter rich text content.</Description>

    <IsIncluded>true</IsIncluded>

    <ZoneID>FullPage</ZoneID>

    <PartOrder>0</PartOrder>

    <FrameState>Normal</FrameState>

    <Height />

    <Width />

    <AllowRemove>true</AllowRemove>

    <AllowZoneChange>true</AllowZoneChange>

    <AllowMinimize>true</AllowMinimize>

    <AllowConnect>true</AllowConnect>

    <AllowEdit>true</AllowEdit>

    <AllowHide>true</AllowHide>

    <IsVisible>true</IsVisible>

    <DetailLink />

    <HelpLink />

    <HelpMode>Modeless</HelpMode>

    <Dir>Default</Dir>

    <PartImageSmall />

    <MissingAssembly>Cannot import this Web Part.</MissingAssembly>

    <PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>

    <IsIncludedFilter />

    <Assembly>Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>

    <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>

    <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">/Lists/JavaScript/TextFiles/Alert Box.txt</ContentLink>

    <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />

    <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />

    </WebPart>]]>

    </AllUsersWebPart>

    </File>

    More Code…
    **************************************************************


    How do I represent a subsite name programmatically within the Elements.xml file so that the feature can be activated on any site without a text file url problem?


    I am fairly new to SharePoint 2010 development so I might be doing something o
    bviously wrong. I hope you can help.
    CEStar

    • Edited by CEStar Friday, December 02, 2011 10:17 AM
    Friday, December 02, 2011 10:14 AM

Answers

  • I have found the solution:

    <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">~site/Lists/JavaScript/TextFiles/Alert Box.txt</ContentLink>

    Or

    <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">~siteCollection/Lists/JavaScript/TextFiles/Alert Box.txt</ContentLink>


    • Edited by CEStar Friday, December 02, 2011 8:39 PM
    • Marked as answer by CEStar Friday, December 02, 2011 8:39 PM
    Friday, December 02, 2011 8:22 PM

All replies

  • Hi.

    One initial question...is the textfile Alert Box.txt located on every site or just one?
    (Do you absolutely have to have a space in the filename? ;-) )

    The trick with relative links is to have it start from where the component that is using it is located, so if it is the webpart that uses the URL, it should be relative from there...

    Regard

     

     

     


    Thomas Balkeståhl - Technical Specialist - SharePoint - http://blksthl.wordpress.com
    Friday, December 02, 2011 11:16 AM
  • I have found the solution:

    <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">~site/Lists/JavaScript/TextFiles/Alert Box.txt</ContentLink>

    Or

    <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">~siteCollection/Lists/JavaScript/TextFiles/Alert Box.txt</ContentLink>


    • Edited by CEStar Friday, December 02, 2011 8:39 PM
    • Marked as answer by CEStar Friday, December 02, 2011 8:39 PM
    Friday, December 02, 2011 8:22 PM
  • Hi I also have the same issue but no luck with above solution

    I  am adding content link property of ContentEditor web part in page layout but I am still getting error.

    <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">/sites/Testsite/Style Library/Content.txt</ContentLink>
        </WebPart></WebPartPages:ContentEditorWebPart>


    <WebPartPages:ContentEditorWebPart webpart="true" runat="server" __MarkupType="xmlmarkup" __WebPartId="{B55D6380-DDB7-43AF-BC5A-8A68A7849C9B}">
    <WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
    <Title>Content</Title>
        <Description>Allows authors to enter rich text content.</Description>
    <PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge>
        <ID>g_b55d6380_ddb7_43af_bc5a_8a68a7849c9b</ID>
        <FrameType>Default</FrameType>
    <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">/sites/Testsite/Style Library/Content.txt</ContentLink>
        </WebPart></WebPartPages:ContentEditorWebPart>

    My question is how can i give ContenLink property declaratively in page layout..?

    I need to link text file from style library to content editor web part in page layout.


    srinivas



    Wednesday, March 06, 2013 2:08 PM