dynamically create new site with custom , web parts and OOB Events, etc embedded
-
2012年8月22日 10:05
hi,
i want to create a site programmaticaly when i click on a button in a visual web part. i have the code for creating a site dynamically, but my issue is, i cant use the team site/doc workspace site , it should be a custom site template/web template which should contain the below ones:
- Out Of Box Events
- Announcements -- may be a Customized announcements WebPart
- OOB Discussion Threads/forums
- Blogs Template
- Wiki Template
- Top users of the site web part - who uses the site reading/ uploading the docs
- My custom web part2
- a web part which shows documents uploaded in that site
how can i create a site having the above web parts/ OOB features, dynamically?
any help is appreciated in terms of sample code,links ..
thnx
Benjamin
すべての返信
-
2012年8月22日 11:44
Hi Benajamin KNR,
do you have that custom site in your site template?
below link can be useful to you. You may need to find your site template id.
Thanks and Regards, Shailesh B. Davara
-
2012年8月22日 14:48
hi benjamin
1- create a sample subsite
2-Customize it(add events, webparts, ...)
3-Create a template from customized subsite
4-create new sites from that template
using (SPWeb myWeb = properties.OpenWeb()) { foreach (SPWebTemplate template in myWeb.Site.GetWebTemplates(myWeb.Language)) { if (template.Title.Equals("Custom Site Template Title", StringComparison.CurrentCultureIgnoreCase)) { SPWeb newSite = myWeb.Webs.Add(url, Title, Description, myWeb.Language, template.Name, false, false); newSite.Update(); } } }
yaşamak bir eylemdir
- 回答としてマーク Qiao WeiMicrosoft Contingent Staff, Moderator 2012年9月2日 4:52
-
2012年8月24日 4:27
Ilker AlizatVi thnx for reply.
but plz let me know if i create a team site which has the blog site created, wiki site created,. custom announcements, discussion forums and added some site pages which has those custom web parts added into the site pages and i wnat to implement a custom master page also int his site with custom navigation/ bread crumbs, etc ..
soo my doubt is shud i go with a custom site definition / web template or
simply save site as a template and i will use this saved template for creating new sites?
which one would be the best approach
thnx
-
2012年8月31日 6:15モデレータ
Hi Benjamin,
As for using custom site definition or save site as template, you may check whether the template through saving as template can meet your requirement, if so, you can choose to use it as it is easier than custom site definition.
Thank,
Qiao Wei
TechNet Community Support
- 回答としてマーク Qiao WeiMicrosoft Contingent Staff, Moderator 2012年9月2日 4:52
- 回答としてマークされていない Benjamin KNR 2012年9月20日 5:46
-
2012年9月17日 5:01
thanks Qiao Wei,
but its not meeting my requirement. if i create a team site with blog site as sub site and if i save this as a template and deploy this another box and tried to create a new site based on this template
the permissions will be an issue. also it wont inherit the name of the new site created.assume if i name the site template name as CommunitySiteTemplate. am sure the blog site would be created but the name of the blog site is not the same as the site name we are creating newly. also we need the members of the blog site should NOT create a new category, only owners group people shud be able to create a a new category in that blog site.
because of these issues, i want to create the site [ site and its subsite -blog site-] on the fly. permissions is going to become an issue in my requirement.
so, if you can help me solving my issue , plz advice.

