Document directory
- View site Object Attributes
SPCAMLEditor-flexible and practical CAML editing tool
(I)
View the word version:Spcamleditor_camlediting tool 1.doc
CAML Overview
CAML stands for Collaborative Application Markup Language, which is translated into a Collaborative Application Markup Language. It is an XML-based Language. SharePoint uses CAML to describe the attribute settings of various objects and define the display style and logic of views. In SharePoint, CAML shadows, field definitions, list definitions, view definitions, content types, and site definitions are all implemented using CAML. It can be said that CAML "binds" various elements (pages, fields, DLL) in SHAREPOINT together. Understanding or even proficient in CAML is necessary for SHAREPOINT developers.
This article will briefly introduce CAML and introduce a CAML editing tool-SPCAMLEditor. Using SPCAMLEditor to modify the CAML definition of site objects is a "unique" SharePoint customization method, you can "quickly" some common functions.
I cannot call CAML "proficient", but I can only count on "getting a glimpse of it". I hope this article will serve as a reference for me.
Introduction to SPCAMLEditor
SPCAMLEditor is a tool used to modify attributes and CAML definitions of SharePoint site objects. It provides smart prompts during CAML editing, enabling instant preview of view CAML editing. With this tool, you can easily modify the Schema definition of the view and list column to implement some special functions.
View site Object Attributes
A SharePoint object generally has two types of attributes: simple attributes and Schema attributes. Simple attributes are defined by simple types. Schema attributes are generally string types, and the content in the string is actually the CAML Definition of the object. SPCAMLEditor allows you to conveniently view all the attributes of a site object.
Usage:
Use the File-> Open menu to enter the site URL to Open the site. For example.
Right-click any node in the navigation tree, and an operation menu appears. You can use the Property item to view or modify the attributes of an object, for example:
After an object is selected, you can use the SchemaXml tag to view the CAML definitions of the content type, list, view, and list fields. For example:
Modifying site Object Attributes
By modifying the attributes of a SharePoint object, we can customize the appearance and behavior of the site. The SharePoint website management provides the setting function of some object attributes, however, there are still many property configurations that are "hidden". We can only control them by writing code through the object model. With SPCAMLEditor, you can easily configure attributes that can be modified by site objects.
We often encounter the following requirement: fields that can be displayed or edited on the Control List form page. This can be easily implemented through SPCAMLEditor.
The following shows how to hide the completion percentage column of the task list from the new page.
Procedure:
Step 1:Find the column to be modified.
Use SPCAMLEditor to open the site, expand the task list to be modified, expand the Fields node, and find the completion percentage column. For example:
Step 2:Call up the Attribute Modification window.
Right-click the Property menu to bring up the Property modification window.
Step 3:Modify the attribute value.
Change the ShowInDisplayForm attribute value to False and click OK.
Step 4: Finally, you can check the effect on the site:
The new page before modification:
New Page after modification:
Custom SharePoint list bar
Minor changes to the List bar are often required when we customize SHAREPOINT. We generally use the following methods to achieve this:
- Use SharePoint Designer to convert the list webpart into a data view, and then modify xslt.
- Self-developed field types.
Method 1 is relatively simple, but some functions are lost after the list is converted to a data view, such as dynamic modification of View fields.
Method 2 is the most flexible, but the disadvantage is the trouble. To develop a field type, write xml, write a class that inherits from SPField, and then write a class that inherits from BaseFieldControls, then deploy it to GAC. Of course, it is worthwhile if we do these jobs to implement a common function. However, if it is only for "special" needs, it would be a waste of code ".
So is there any better way? Is it simple and can be perfectly integrated with the system mechanism?
The answer is SPCAMLEditor.
With SPCAMLEditor, you can directly modify the Schema of a field or create a field with a new Schema.
The following is an actual example.
Function Description: Add a chain bar on the list page. Click this link to go to a page (/_ layouts/page1.aspx) and pass the ID of the current list item as a parameter (page1.aspx? ID = 1 ).
Procedure:
Step 1:Create a new field based on an existing field.
Use SPCAMLEditor to open the site, find the list to be modified, and expand the Fields node. For example:
Generally, we use the system's "edit" field as the template to copy a new field.
Find the "edit" field and create a new field by right-clicking Copy in the menu.
Note: When creating a new field, errors may occur sometimes, but it doesn't matter. If an error occurs, refresh the interface using the Reflash button on the toolbar and find the new field:
Select this field and click the DisplayPattern node in the SchemaXml tab.
DisplayPattern defines the Field Rendering logic. For example:
We can take a closer look at the DisplayPattern content, which is a standard CAML statement.
IfHasRights and rightschices specify that the field content is displayed only when the user has the EditListItem permission.
<URL Cmd = "Edit"/> outputs the URL of the editing page of the current list item. Note the GoToLink function. This JS function will automatically append the URL of the current page to the Edit page. When we link to the form page, the page URL is in the following format: DispForm. aspx? ID = 17 & Source = XXX. This Source parameter is appended to the GoToLink function.
The following table lists some common CAML labels. For more labels, see SDK.
CAML label |
Description |
Example |
HTML |
Output HTML |
<HTML> <! [CDATA ["]> </HTML> |
Column |
Output field value, |
Current Field: <Column/> Specify other field names: <Column Name = "Title"/> |
Field |
A complete field is output to combine the output of several fields. The difference between Filed and Column is that Column only contains values, and Field usually contains not only values but also other HTML |
Current Field: <Field/> Other fields: <Field Name = "Title"/> |
Property |
Attribute of the output field. Select is used to specify the attribute name. |
<Property Select = 'displayname' URLEncode = "TRUE"/> |
URL |
Output URL related to the current list item |
View page: <URL Cmd = "Display"/> Edit page: <URL Cmd = "Edit"/> Create page: <URL Cmd = "New"/> |
Now |
Output Current Time |
<Now/> |
Step 2: Modify the field name
Right-click a field and choose "Property" from the shortcut menu to bring up the field Property modification form. Modify the Title Property to "view associated data" and click "OK" to save the modification.
Step 3: Modify the DisplayPattern content
We do not need to control the permissions of this link, so we do not need the IfHasRights tag. Select the DisplayPattern node and change its content to the following:
<DisplayPattern>
<HTML> <! [CDATA [<a href = "/_ layouts/page1.aspx? ID =]> </HTML>
<Column Name = "ID"/>
<HTML> <! [CDATA ["onclick =" GoToLink (this); return false; "target =" _ self ">]> </HTML>
<HTML> View associated data </HTML>
<HTML> <! [CDATA [</a>]> </HTML>
</DisplayPattern>
The preceding CAML definition is simple. The HTMl of the output link uses the Column label to embed the ID of the current list item.
Step 4: preview or save
By default, SPCAMLEditor does not provide the instant preview function for modifying the field Schema. You must manually Save the modification of the field (by right-clicking the Update menu item in the menu) to view the effect. Sometimes we need to frequently test and view the effect when developing a field. It is annoying to click the Update menu for each modification. We can configure the settings so that SPCAMLEditor automatically saves the changes during previewing, for example:
Note: Modification of system fields may cause errors. Be cautious when modifying the system fields. You can save the Schema of the field before modification. If an error occurs, overwrite it back. You can modify the newly created read.
Here, we set to allow automatic saving of field modifications and switch to the Preview tab to see the modification results:
Step 5:Add fields to the view
First, use the Property menu item to find the InternalName of this field. In my environment, it is _ x7f16 _ x8f91 _ Copy, for example:
Then, click the view where this field is to be placed and add _ x7f16 _ x8f91 _ Copy to the ViewFields node.
Click the Update menu of the view node to complete the modification.
The links in SPCAMLEditor are not allowed to be clicked. We can use IE to open the site and view the final effect of customization.
This is a simple example. Based on this example, you can expand more features, such as opening a new window using the JS script window. open.
I have written more complex examples. If you are interested, refer to these two articles:
Implement the video player field:
Http://www.cnblogs.com/jianyi0115/archive/2008/04/28/1175259.html
Implement the sequence number field:
Http://www.cnblogs.com/jianyi0115/archive/2008/05/28/1209039.html
How to Get SPCAMLEditor
To download the latest version of SPCAMLEditor, go to http://www.codeplex.com/spcamleditor. When the software is running for the first time, some DLL will be registered, and a console window will appear. Ignore it.
Note:: SPCAMLEditor accesses SharePonit through the object model, and the object model is only available on the server. Therefore, this tool can only be used on the SharePoint Server.