locked
Site Templates and Master Page RRS feed

  • Question

  • Hi,

    We are using a site template to create sites under the root site collection. So many sites has been created using this site templates. Now I wanted to update master page associated with all these sites  with a javascript code. How can I achive this?

    Thanks in advance !!

    Monday, June 8, 2009 6:44 PM

Answers

  • Masterpages and page layouts are stored in the root web of the site collection.  So if you have one site collection and many sub sites you can do the following:

    You need to go into the Site Collection Root, either using SharePoint designer or a web browser.  Using SPD expand the _catalogs folder and masterpage folder, check-out your masterpage, make your changes and check-in and publish.  Uisng a web browser you need to go to the site collection root web, site actions, site settings, masterpage and page layouts gallery, download a copy of the file, make changes and upload file (make new version is published).

    If you have one root site collection and many site collections in the "sites" folder you will need to repeat for each or have a look at this STSADM extension I created http://uploadplmp.codeplex.com/.  It will allow you to upload files to the masterpage and page layouts gallery, so you could download the file, install the STSADM extension, write a batch file which has calls to STSADM -O uploadmasterpagesandpagelayouts specifying the different urls to the site collections.

    Hope this helps

    Dave
    My SharePoint Blog - http://www.davehunter.co.uk/blog
    Tuesday, June 9, 2009 9:55 AM

All replies

  • Hi,

    Maybe I misunderstood your question, but I feel some mismatch is there. JavaScript typically a client side programming language while the master page is a server side term related to ASP.NET.

    What do you mean by updating the associated master pages? Associate a new master page (option A) or update the content of the existing one (option B)? To update the existing master page (option B) you should upload a new version of the existing master page, to associate a new one, you should upload the new master page to the master page gallery (if it is not already there), and set it the system master page / site master page depending if it is a publishing site or not (see: The difference between Site Master Page and System Master Page, http://pointstoshare.spaces.live.com/blog/cns!AEC42F315B4528B0!2864.entry?sa=956055762)

    Please, let us know why you need to use JavaScript!

    Peter
    Monday, June 8, 2009 7:13 PM
  • Sorry, I did not put my question properly

    As I'm using a site template to create each site, every site will have its own master page. Now I want to update these master page with a javascript(google analytic javscript block) to each master page. So that I will get the Site Usage report.

    There are around 2000 Sites under the root site collection, now how do I update the master page of each site to append this google analytics javascript code?

    Hope its understandable now !!
    • Edited by Sanban Tuesday, June 9, 2009 9:36 AM edited
    Tuesday, June 9, 2009 9:35 AM
  • Masterpages and page layouts are stored in the root web of the site collection.  So if you have one site collection and many sub sites you can do the following:

    You need to go into the Site Collection Root, either using SharePoint designer or a web browser.  Using SPD expand the _catalogs folder and masterpage folder, check-out your masterpage, make your changes and check-in and publish.  Uisng a web browser you need to go to the site collection root web, site actions, site settings, masterpage and page layouts gallery, download a copy of the file, make changes and upload file (make new version is published).

    If you have one root site collection and many site collections in the "sites" folder you will need to repeat for each or have a look at this STSADM extension I created http://uploadplmp.codeplex.com/.  It will allow you to upload files to the masterpage and page layouts gallery, so you could download the file, install the STSADM extension, write a batch file which has calls to STSADM -O uploadmasterpagesandpagelayouts specifying the different urls to the site collections.

    Hope this helps

    Dave
    My SharePoint Blog - http://www.davehunter.co.uk/blog
    Tuesday, June 9, 2009 9:55 AM
  • Hi,

    But if the content of the master pages is different site by site, I don't know any tool that can help you to automate the process of inserting the script block. As the place of the script is rather predeterministic, you can create a simple tool that reads the content of the master page into a string, finds the insertion point for the script block, inserts it, and writes back to the master page gallery. Don't forget to check in the changes to make the master page available for visitors.

    Peter
    Tuesday, June 9, 2009 10:09 AM
  • Do you have any .js files already? May be you could try including this javascript block in it so that it will be picked up by all master pages?

    Else, create a new javascript file with this code and you have to update the changes either by writing a console app or using SharePoint Designer as others have pointed out.
    Regards,
    Chakkaradeep

    Twitter: http://twitter.com/chakkaradeep
    Blog: http://www.chakkaradeep.com
    Tuesday, June 9, 2009 10:13 AM