Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I would like to have the text file associated with my content editor change based upon the query string.

?division=Name

Content Editor link: /site assets/[QueryStringResult].txt

share|improve this question
    
I am not aware of anyway to do this but you could achieve the same result by adding some jQuery to your text file which altered the output based on the query string parameter? –  Dave Paylor Mar 15 '13 at 21:59
    
Dave, Thank you. Yes, These documents already exsists, so I was just hoping there was a way to utilize the existing files. But there is possibly not away to do this. Thanks again –  Shelly Miner Mar 16 '13 at 0:52
add comment

1 Answer 1

It could be achieved by generating url for the asset on the client side and passing it to iframe for displaying asset content in Content Editor web part.

Usage

Clear ContentLink property

Put in Content property of the following code:

<iframe width="100%" id="assetContent"  frameborder="0"></iframe>


<script type="text/javascript">

//get query string value
function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.search);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

function renderAssetContent() 
{
    var division = getParameterByName("division");
    if (division.length > 0){
        var assetUrl = "/teamsite/itdepteamsite/SiteAssets/" + division + ".txt"; 

        var assetContent = document.getElementById("assetContent");
        assetContent.setAttribute("src", assetUrl);
    }
}

renderAssetContent();
</script>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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