0

I have added a ContentEditorWebPart to an Element file in visual studio. I want to get the current site url and place it in the content block (between the cewp:Content tags).

How would i do this?

Please note i am in a sandboxed solution so this is the only way i can add a ContentEditorWebPart. How do i reference the current site url using the code below?

  AllUsersWebPart WebPartZoneID="FullPage1" WebPartOrder="0"
    ![CDATA[
                WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" xmlns:cewp="http://schemas.microsoft.com/WebPart/v2/ContentEditor"
                AssemblyMicrosoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c/Assembly
                TypeNameMicrosoft.SharePoint.WebPartPages.ContentEditorWebPart/TypeName
                TitleStructral Site Text/Title
                FrameTypeNone/FrameType
                cewp:Content
                  This is some content with a link. a href="http://mysite.com/mysubsite/"/a
                /cewp:Content
                /WebPart
                ]]
  /AllUsersWebPart
1

You could add some js script and use the _spPageContextInfo object.

 This is some content with a link. <a id="siteUrl">click here</a>   
<script language="JavaScript">
    document.getElementById('siteUrl').setAttribute('href', _spPageContextInfo.webServerRelativeUrl);
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.