how do i add a view to schema.xml in sharepoint - sharepoint

I am trying to add a view to a custom list. The target is MOSS 2007, I am using VS2008 w/ VSeWSS 1.3. The feature already has a custom list definition, including a custom view called "Calendar". To get started I thought I'd create another view called NewCalendar that is simply a duplicate of the existing custom view Calendar.
So, I copied Calendar.aspx to NewCalendar.aspx, copied the existing "View" node for the current calendar and pasted a new node, then changed the following attributes of the new node: DisplayName, Url, and DefaultView.
When I refresh WSP View NewCalendar.aspx shows up. When I deploy and go to NewCalendar.aspx i get a 404. Using SharePoint Manager I confirm the page is not present.
How do I add a custom view via a feature so that it shows up in the "View" drop-down?
UPDATE: It works if I create a new instance of my custom list. How do I get the custom view to show up on existing lists?

Unfortunately features in general are not retroactive. You cannot update a feature and expect all existing items that were created from that feature to be updated. This i assume is by design. If this were possible it could potentially have far reaching (unexpected) consequences.
In these senario's i script out a retrofit script, when publishing the new feature.

Related

One time javascript function run in custom action

I have a request from the customer that they want every time they create a subsite (publishing site) .We have to add a custom column to OOTB Documents list.
I have done some researching the way to add the custom column to
Documents list in onet.xml but have no luck .
Then i think about the work around solution that i create a
ScriptBlock custom action that will call javascript function which
will add the custom column to document list , then i will put this
custom action to a feature ,and finally i will reference that feature
in onet.xml.
It run well but the javascript function call every time i refresh the page. I just want it run one time when i active the feature.
Does anyone have any suggestion ? I use sandbox solution and Sharepoint Online .Sorry for my bad English
I don't think a custom action is the right way to do this, Custom actions generally need some sort of user interaction.
Get CKS dev tools in Visual studio
Create a new SharePoint solution
Add a new web template(CKS Dev) to your solution from the Add new item menu in VS
Create an additional feature (web) with a list template (Your documents Library and add your column)
Update the Web templates onet file
Also sometimes it's better to put up what your having issues with as you have said you have had no luck with the above, What is the issue you are having, Post some code up etc rather than going down the route of changing the way you implement the solution
Many Thanks
Truez

How to create a sharepoint 2010 template that will dynamically update its child sites

I recently created a site in Sharepoint 2010, and I have saved it as a template. I'm able to apply this template to new sites, which is great. I can then add new data to each site individually. However, my problem is that if I want to change something on every child site, I would have to go through manually and do so. Is there any way that I can create a template that will work dynamically so that I can make changes to the original and all the child sites will inherit these changes?
Unfortunately not how you are requesting. When a site is created it uses a site template, including your own custom site template. Once a site has been created there is no way to reapply a site template to that existing site. You could use PowerShell to update a series of existing sites but the commands would get quite complex.
If you have deployed new site collections using a globally deployed template and you change that template using SharePoint designer, you should not have any issues and changes will be automatically applied to child sites unless you change master page.

SharePoint 2010 v4.master inheritance

I made a change to my v4 master at the application level to hide a certain piece of HTML code (the developer dashboard to be specific). I assumed I could edit it at the application level and then all site collections created within that application would inherit the changed v4 master and hide the element.
This is not the case though... in addition, I tried to edit the master in 14\TEMPLATES\LAYOUTS with no success either.
The only thing I have gotten to work is editing the v4 in SP designer at the site level (which is unaccepable to me as I want to provision a new site collection and not have to manually change this every time).
Any suggestions / known fixes for the issue I am encountering?
Try to hide what do you want thru style sheet CSS or don't update the default v4 mater page not recommended, create a new copy of V4 and do you updates then create Staplers features and on every site collection created change it's master page to the new one yo have created and for the old created site collection run thru code and activate the Staplee feature on each site collection to do the same.

Which is the better approach in custom pages?

I want to create a custom new item page for sharepoint but there are two approached that I
can use and I want to share your experience in determining which is better.
The first: is to create a page in a library then create a C# library project to handle
the events of the controls on the page.
The second: is to define a feature of the content type of my list and specify the new
item form to be my custom form, then create a website containing the custom form and put
this site at the layouts folder.
for me the first approach is fine but the problem is that a user may access the default
sharepoint new item form which I don't want to happen.
but I don't like the idea of placing the form in a library on the site.
so which is better in your opinion ?
thanks
i suggest you to go with your second approach ...
Create a completely new feature that allows you add your functionalty of page creation and any customization realted to that and deploy this one to the 12 hive features folder as a new feature and every time you want have such a page created you can you this template and create the page...
Well, frankly, I'm confused by both of your suggestions.
I don't see how the first one would ever work.
And the second one; you don't "put sites in the layouts folder".
Here's what I would suggest you to do:
Download and install the WSS Extensions for Visual Studio.
Create a List Definition using these new templates.
Copy the NewForm.aspx from the 12 hive and Customize it.
Download and install the WSP Builder from Codeplex.com
Add your custom list definitions and files to a new Feature project in WSP Builder.
Package the Feature up to a .wsp using WSP Builder and you are good to go.
Your custom page(s) should be placed in your custom folders in my opinion.
Hope this helps.
Your concern in the first approach is that people will still be able to access the default form. If you are not opposed to using a custom control template for a content type definition, I recommend creating a very simple redirect control template and assigning it to the content type's "New Form". Such a control template need only contain one custom control, which has an OnInit or OnLoad method that contains little more than a Page.Response.Redirect call. Make that redirect point to the page you create in your first approach, and now whenever anyone tries to access the default new form for that content type, they will instead be directed to your custom page with all of your custom code. It is perhaps a bit of a hack, but it's definitely functional.

Sharepoint: Deploy Custom Lists and New Columns in lists

I've created a custom list & also added a column in the Announcement List. Question is, how can I include those newly created items when I create a fresh Web Application (like a script, feature or something)?
Additional Info: It's like when you're to deploy from your development machine to a staging or production server. I'd like to have a script or something to update my production server to have the new column i've added to the Announcement List. Just like SQL Server's ALTER TABLE command to update a SQL Server Table.
Is there an equivalent in Sharepoint Lists?
TIA!
Regarding the new custom list, this can be done using features. See How to: Create a Custom List Definition for more information. The Visual Studio Extensions for SharePoint (VS2005 / VS2008) will help you to extract the list definition if you've created it through the SharePoint UI. If you are fortunate enough to be using a custom site definition and don't have any webs created yet, you can set your site definition to create the custom list using feature stapling.
If you are attempting to apply these changes to webs that already exist, you can still use a feature to define your custom list. It will just appear as a type of list that can be created. Then to have the custom list automatically created for existing webs or to modify existing lists such as the Announcements list, you can use a feature receiver. This allows you to run any custom code when the feature is activated. See the MSDN article Feature Events for more information.
Alternatively, you could not use features at all as they can be difficult, time consuming and painful. In fact, this blog post has a good argument against the idea. You could try the tool mentioned on that page or other applications such as DocAve Content Manager and SharePoint Site Migration Manager.
Your question is not very clear but I think you may want to look at Application Templates.
Microsoft provide 40 pre-built templates in the link below and the same technology is available to you. Links from this page should lead you to information showing you how you can crate your own.
Application Templates for Windows SharePoint Services 3.0
http://technet.microsoft.com/en-us/windowsserver/sharepoint/bb407286.aspx

Resources