I am creating a site which will tie in to numerous affiliate sites. Each of these affiliates has different javascript that needs to be added to the header contents of the page. I would like to just use one template with a contentplaceholder and add the script dynamically. I've tried adding a textbox multiple on the doctype and then adding an umbraco item within the contentplaceholder but I get a potentially dangerous code error when trying to save and publish. Am I missing something ... am I going about this the wrong way .... does anyone have any ideas?
Maybe you can create a javascript files "pool" somewhere in your site structure and then add a multipicker as document type property, pointing to that pool. Then you only need to create a macro which you can integrate in your contentplaceholder, to get the list of items selected on the document and generate the proper JavaScript includes.
I have tried to reply to your post 3 times now, and each time our seems to be letting me down and not saving it, so you might end up with three responses, or none!
I agree with Mike that you should probably do this using a XSLT or .NET macro.
You might find that the ability to add XSLT files anywhere on a page is also useful, have a look at the following WIKI page:
Adding Javascript to header contents dynamically
I am creating a site which will tie in to numerous affiliate sites. Each of these affiliates has different javascript that needs to be added to the header contents of the page. I would like to just use one template with a contentplaceholder and add the script dynamically. I've tried adding a textbox multiple on the doctype and then adding an umbraco item within the contentplaceholder but I get a potentially dangerous code error when trying to save and publish. Am I missing something ... am I going about this the wrong way .... does anyone have any ideas?
Hi David,
Maybe you can create a javascript files "pool" somewhere in your site structure and then add a multipicker as document type property, pointing to that pool. Then you only need to create a macro which you can integrate in your contentplaceholder, to get the list of items selected on the document and generate the proper JavaScript includes.
Hope this helps.
Cheers,
Michael.
Hi David,
I have tried to reply to your post 3 times now, and each time our seems to be letting me down and not saving it, so you might end up with three responses, or none!
I agree with Mike that you should probably do this using a XSLT or .NET macro.
You might find that the ability to add XSLT files anywhere on a page is also useful, have a look at the following WIKI page:
http://our.umbraco.org/wiki/reference/umbracolibrary/registerjavascriptfile
Cheers,
Chris
is working on a reply...