from the front, and one
from the end. Trimming is not done, and nothing is done if the string is less than 5 characters long. If the string starts with a P tag but does not end with a closing P tag, only the opening P tag is removed (middle-content of the string is not modified). - -###Example -| Event | -Signature | -Description | -
|---|---|---|
| BeforeSave | -(Document sender, SaveEventArgs args) | -
- Raised before a document is saved from the UI, or when Document.Save() is called in the API. - NOTE: When the event is fired from the UI, then the "sender" will be the current document in the database, and not have the values that are about to be saved. - |
-
| AfterSave | -(Document sender, SaveEventArgs args) | -- Raised after a document is saved from the UI, or when Document.Save() is called in the API. - | -
| BeforeSendToPublish | -(Document sender, SendToPublishEventArgs args) | -- Raised before a document is sent for publication. Setting args.Cancel = true will cancel the send. - | -
| AfterSendToPublish | -(Document sender, SendToPublishEventArgs args) | -- Raised after a document is sent to publishing. - | -
| BeforePublish | -(Document sender, PublishEventArgs args) | -- Raised before a document is published. Setting args.Cancel = true will cancel the publishing. - | -
| AfterPublish | -(Document sender, PublishEventArgs args) | -- Raised after a document is published. - | -
| BeforeUnPublish | -(Document sender, UnPublishEventArgs args) | -- Raised before a document is unpublished. Setting args.Cancel = true will cancel the unpublishing. - | -
| AfterUnPublish | -(Document sender, UnPublishEventArgs args) | -- Raised after a document is unpublished. - | -
| BeforeCopy | -(Document sender, CopyEventArgs args) | -
- Raised before a document is copied. Setting args.Cancel = true will cancel the copy. - args.CopyTo contains the id of the target parent node. - |
-
| AfterCopy | -(Document sender, CopyEventArgs args) | -
- Raised after a document is copied. - args.NewDocument contains the newly created copy. - |
-
| BeforeMoveToTrash | -(Document sender, MoveToTrashEventArgs args) | -- Raised before a document is moved to trash. Setting args.Cancel = true will cancel the move. - | -
| AfterMoveToTrash | -(Document sender, MoveToTrashEventArgs args) | -- Raised after a document is moved to trash. - | -
| BeforeDelete | -(Document sender, DeleteEventArgs args) | -- Raised before a document is deleted from the trashbin. Setting args.Cancel = true will cancel the delete. - | -
| AfterDelete | -(Document sender, DeleteEventArgs args) | -- Raised after a document is delete from the trashbin. - | -
| BeforeRollBack | -(Document sender, RollBackEventArgs args) | -- Raised before a document is rolled back to a previous version. Setting args.Cancel = true will cancel the rollback. - | -
| AfterRollBack | -(Document sender, RollBackEventArgs args) | -- Raised after a document is rolled back to a previous version. - | -
hello
"; - - -###.HasChildren -Returns `Bool` indicating whether the given `Document` has any documents just below it - - -###.Id -Returns the unique `Document` Id as a `Int`, this ID is based on a Database identity field, and is therefore not safe to reference in code which are moved between different instances, use UniqueId instead. - -###.IsTrashed -Returns a `Bool` indicating whether the given `Document` is currently in the recycle bin. - - -###.Level; -Returns the given `Document` level in the site hirachy as an `Int`. Documents placed at the root of the site, will return 1, documents just underneath will return 2, and so on. - -###.OptimizedMode -Indicates whether the Document was initialized with a single SQL query, loading all data in one go, instead of lazy-loading each individual property. -**Notice:** this indicator does in general not do anything internally. - - -###.Parent -Returns a `CMSNode` object, representing the Parent document, if no parent is available, an exception will be thrown. **Notice:** `CMSNode` is the object which `Document` inherits from, and does therefore not allow access to all properties. - - -###.ParentId -Returns the parent `Document` Id as an `Int` - -###.Published -Returns a Bool indicating whether the given `Document` is published and available on the website or not. **Notice:** the published flag does not check the current in-memory cache, so this flag is not a guarantee the Document is/is not available in the cache and the website - -###.Relations -Returns a `Relation` array with all relations relevant to the given `Document`. This both returns parent and child relations - - var doc = new Documnet(1234); - foreach(var rel in doc.Relations){ - //returns a Relation object containing type, child, parent and ID - var child = rel.Child; - var type = rel.RelType.Alias; - } - - -###.ReleaseDate -If set, returns `DateTime` indicating when the `Document` should be published and made available on the website and cache. - -###.sortOrder -Returns the given `Document` index, compared to sibling documents. - -###.Template -Returns the ID of the currently set template as a `Int` - -###.Text -Returns the name of the document as a `String` - -###.UniqueId -Returns the `Guid` assigned to the Document during creation. This value is unique, and should never change, even if the document moved between instances. - - -###.UpdateDate -Returns a `DateTime` object, indicating the last the given Document was updated. - -###.User -Returns the `User` who created the Document, same as `Creator` - -###.UserId; -Returns the ID of the creator/user, as a `Int` - -###.Version; -Returns the current Version ID as a `Guid`, -For each change made to a document, its values are stored under a new Version. This version is identified by a `Guid` - -###.VersionDate -Returns the `DateTime` this specific version was created, not the Document itself. - - -###.Writer -Returns a `User` object, of the user who made the latest edit on the Document. - - -##Methods -###.Copy(1233, User, false) -Recreates the given Document as a child of the given Id, a User is based for the audit trailm and a boolean value indicates whether a relation between original and copy should be made. Method returns the copy as a `Document` - - //Get the document to copy - var doc = new Document(1234); - //create as a child of node with Id 1234 - doc.Copy(1234, new User(0), true); - - -###.delete(true) -Deletes the given `Document`, a `Bool` can be passed to indicate whether the Document should be deleted, or simply moved to the Recycle bin, **notice** you will need to remove the document from the cache as well - - var doc = new Document(1223); - umbraco.library.UnpublishSingleDocument(doc.id); - doc.delete(true); - -###.getProperty(alias) -Returns a `Property` with the given alias. The properties contain the document data, the property data is instantly persisted. - - var doc = new Document(1234); - doc.getProperty("bodyText").Value = "hello
"; - doc.getProperty("dateField").Valye = DateTime.Now; - - -###.GetTextPath() -Returns the parent Ids as a path to the given `Document`. If a document exist underneath a Document with ID 1234, which then exist under a document with id 5555, the TextPath returned is -1,5555,1234 - -###.GetVersions() -Returns a `DocumentVersionList` containing all previous versions of the given Document. each version contains a date, the name of the Document, user, and the unque version ID. - - foreach(var version in d.GetVersions()){ - var date = version.Date; - var name = version.Text; - var uniqueId = version.Version - } - -###.HasPendingChanges() -Returns a `Bool` indicating whether there has been any property/data changes since the last time this Document was published. - -###.HasPublishedVersion() -Returns a `Bool` indicating whether the given Document has been published previously. - -###.Move(1234) -Moves the Document, and places it as a child under the the Document with the given ID. - - //get the document - var doc = new Document(1234); - //move it underneath the document with Id 5555 - doc.Move(5555); - //publish the changes - doc.Publish() - umbraco.library.UpdateDocumentCache(doc.Id); - -###.Publish(user) -Creates a new Xml Representation of the current Document, and creates a new version of document, for continued editing. -**Notice:** Publishing a document, is a 2 step operation, first exposing a Xml representation of the current state of the document, and afterwards pushing this xml into the in memory xml cache. - - //Get the document - var doc = new Document(1234); - - //create and store a xml representation of the document - doc.Publish(user); - - //tell the runtime to retrieve the xml from the database and store in cache - umbraco.library.UpdateDocumentCache(doc.Id); - - -###.PublishWithChildrenWithResult(user) -Publishes the given Document using Publish(user) and then performs the same .Publish() on all children. - -###.PublishWithResult(user) -Does the same thing as .Publish(user) but returns a `Bool` indicating whether the publish was successfull. - -###.PublishWithSubs(user) - -###.RemoveTemplate() -Sets the template ID to `Null` on the given Document - -###.RollBack(VersionId, user) -Rolls the `Document` back to the version with the a given Version Id. A user must be passed for the Document audit trail. - -###.Save() -Saves the latest changes on the Document. This triggers the Before/After save events. **Notice** this method is nothing but a stub, as all properties are instantly persisted. - -###.SendToPublication(user) -Sends the Document to publishing, which triggers notifications to the appropriate admins, subscribing to notifications. Send to publishing, is only used in case the current `User` does not have permission to publish a document. - -###.ToPreviewXml(XmlDocument) -Returns a `XmlNode` containing the Document data, based off the latest changes, even unpublished changes, is only used for the internal Preview functionality - -###.ToXml(xmldocument, true) -Returns a `XmlNode` containing the Document data, based off the latest published changes. Is used when the published document is send to the in-memory cache. - -###.UnPublish() -Sets the Published flag to false, which means the Xml will not be included in the Xml Cache the next time it refreshes. **Notice:** to force the document out of the cache instantly, a call to library.UnpublishSingleNode() - - //get the document - var doc = new Document(1234); - - //remove it from the cache - umbraco.library.UnpublishSingleNode(doc.id); - - //mark it as unpublished - doc.UnPublish(); - - -###.XmlGenerate(XmlDocument) -Generates a xml representation of the `Document` and saves it in the database. - -###.XmlNodeRefresh(XmlDocument, ref XmlNode) -Refreshes the given `XmlNode` with data from the Document properties. - -###.XmlPopulate(XmlDocument, ref XmlNode, true) -Populates the given `XmlNode` with data from the Document Properties. A boolean parameter can be passed to indicate whether all child document xml should be append as well. diff --git a/OurUmbraco.Site/Documentation/master/Reference/Management/Documents/index.md b/OurUmbraco.Site/Documentation/master/Reference/Management/Documents/index.md deleted file mode 100644 index 962aed6c..00000000 --- a/OurUmbraco.Site/Documentation/master/Reference/Management/Documents/index.md +++ /dev/null @@ -1,150 +0,0 @@ -#Documents - -The `Document` object represents a page, as it is stored in the database. All calls to the document api, goes directly to the database. It is therefore **not** recommend to be used a query API, as there are faster alternatives which interacts directly with the in-memory content instead. - -All documents are versioned, so on each indiviual change, a new version is stored. Past versions can only be retrieved from the `Document` api, not from the cache. - - * **Namespace:** `umbraco.cms.businesslogic.web` - * **assembly:** `cms.dll` - - -All samples in this document will require references to the following dlls: - -* cms.dll -* businesslogic.dll - -All samples in this document will require the following usings: - - using umbraco.cms.businesslogic.web; - using umbraco.BusinessLogic; - -##Constructor -The Document constructor is used to retrive a Document object with a given Id or Guid, there are optional parameters, which allows one to control setup and version. - -For all constructors, a null is returned if a document is not found with the given id, guid or version. - -###Get Document by Id -Retrieves the latest version of a `Document` by its id, which is a Database identity `int`. -**Notice:** it is recommend to avoid the use of hardcoded Id's in your code, as these will change between environments. - - Document d = new Document(1234); - -###Get Document by Guid -Retrieves the latest version of a `Document` by its guid, which is set on creation - - Document d = new Document(guid); - -if noSetup is set to true, only the Id, property is set on the returned `Document` object, all other properties will not be loaded. - - Document d = new Document(guid, true); - -###Get Document by version -All documents in umbraco is versioned. So everytime a document is changed, a new version is stored seperately. All versions get a unique Id assigned. The document returned will reflect the state of the document data in that specific version. - - - Document d = new Document(1234 versionGuid); - -##Creating a Document and setting properties -To create and store a `Document` you need a `DocumentType`, calling `MakeNew()` the document is instantly persisted and property values can be set. A property expects a object so any value can be set, however, ensure the datatype associated with the property can handle the valuetype. - - DocumentType dt = DocumentType.GetByAlias("Textpage"); - User u = new User(0); - int parentId = 1234; - - Document d = Document.MakeNew("name of document", dt, u, parentId); - //set a string - d.getProperty("bodyText").Value = "Hello"); - //set a date - d.getProperty("date").Value = DateTime.Now; - //set a HttpPostedFile - d.getProperty("upload").Value = Request.Files[0]; - - //publish the document - d.Publish(user); - - //Inform the cache it should update - umbraco.librarh.UpdateDocumentCache(d.Id); - -##[Document methods and properties](document.md) -The `Document` class itself has a big collection of methods and properties, please see the seperate [Document](document.md) page for this. - - -##Static methods -###.CountSubs(1233, false); -Counts the number as a `int` of children below a given document, optional parameter to only return number of published children. - - int result = Document.CountSubs(1233, false); - -###.DeleteFromType(type); -Deletes all documents with a given document type - - var dt = DocumentType.GetByAlias("newsArticle"); - Document.DeleteFromType(dt); - -###.GetChildrenBySearch(1223, "wat"); -Returns children as a `Listhello
"; - media.getProperty("dateField").Value = DateTime.Now; - -###.Move(1234) -Moves the Media, and places it as a child under the the Media with the given ID. - - //get the Media - var media = new Media(1234); - //move it underneath the Media with Id 5555 - media.Move(5555); - //publish the changes - media.Publish() - umbraco.library.UpdateMediaCache(media.Id); - - -###.Save() -Saves the latest changes on the Media. This triggers the Before/After save events. **Notice** this method is nothing but a stub, as all properties are instantly persisted. - -###.ToXml(xmlMedia, true) -Returns a `XmlNode` containing the Media data, based off the latest published changes. Is used when the published Media is send to the in-memory cache. - -###.XmlGenerate(XmlMedia) -Generates a xml representation of the `Media` and saves it in the database. - -###.XmlNodeRefresh(XmlMedia, ref XmlNode) -Refreshes the given `XmlNode` with data from the Media properties. - -###.XmlPopulate(XmlMedia, ref XmlNode, true) -Populates the given `XmlNode` with data from the Media Properties. A boolean parameter can be passed to indicate whether all child Media xml should be append as well. diff --git a/OurUmbraco.Site/Documentation/master/Reference/Management/Relations/index.md b/OurUmbraco.Site/Documentation/master/Reference/Management/Relations/index.md deleted file mode 100644 index 1dacfad5..00000000 --- a/OurUmbraco.Site/Documentation/master/Reference/Management/Relations/index.md +++ /dev/null @@ -1,79 +0,0 @@ -#Relations - -_The `Relation` object represents a connection between 2 items stored in Umbraco, a parent and a child item. All obejcts in a relation must be stored in Umbraco, and have a reference in the UmbracoNode table, and a integer ID, it therefore not possible to build relations between a Umbraco object and a external piece of data._ - - - * **Namespace:** `umbraco.cms.businesslogic.relation` - * **assembly:** `cms.dll` - - -All samples in this document will require references to the following dlls: - -* cms.dll -* businesslogic.dll - -All samples in this document will require the following usings: - - using umbraco.cms.businesslogic.relation; - using umbraco.BusinessLogic; - -(see also: [uQuery Relation Extensions](../../Querying/uQuery/Relations.md)) - -##Constructor -The `Relation` constructor is used to retrive a Relation object with a given Id, a null is returned if no relation is found with the given Id. - -###Get Relation by Id -Retrieves the `Relation` by its id, which is a Database identity `int`. - - Relation r = new Relation(1234); - -##[Relation methods and properties](relation.md) -The `Relation` class itself has a big collection of methods and properties, please see the seperate [Relation](relation.md) page for this. - -##[RelationType methods and properties](relationtype.md) -The `RelationType` class itself is described in a seperate [RelationType](relationtype.md) page. - -##Static methods - -###.GetRelations() -Returns a `Relation[]` containing all relations for a given Node Id, as a optional parameter, you can filter by a specific `RelationType` - - //get relations from a node with a given ID - var relations = Relation.GetRelations(1234); - - foreach (var relation in relations) - { - var date = relation.CreateDate; - var parent = relation.Parent; - var child = relation.Child; - } - - //get relations by a given ID and with a specific relation type - var relType = RelationType.GetByAlias("myRelation"); - var relations = Relation.GetRelations(1234, relType); - -###.GetRelationsAsList() -Returns a `List| Overload Option | Description | -
|---|---|
| .AncestorOrSelf() | -Returns the root item from the current tree | -
| .AncestorOrSelf((int)level) | -Returns the item from the Ancestors collection at the specified level | -
| .AncestorOrSelf((string)nodeTypeAlias) | -Returns the item from the Ancestors collection with the specified nodeTypeAlias | -
Extra info for this item
- } - ---- - -##IsHelper Methods - -###.IsFirst([string valueIfTrue][,string valueIfFalse]) -Test if current node is the first item in the collection - -###.IsNotFirst([string valueIfTrue][,string valueIfFalse]) -Test if current node is not first item in the collection - -###.IsLast([string valueIfTrue][,string valueIfFalse]) -Test if current node is the last item in the collection - -###.IsNotLast([string valueIfTrue][,string valueIfFalse]) -Test if current node is not the last item in the collection - -###.IsPosition(int index[,string valueIfTrue][,string valueIfFalse]) -Test if current node is at the specified index in the collection - -###.IsNotPosition(int index[,string valueIfTrue][,string valueIfFalse]) -Test if current node is not at the specified index in the collection - -###.IsModZero([string valueIfTrue][,string valueIfFalse]) -Test if current node position evenly dividable (modulus) by a given number - -###.IsNotModZero([string valueIfTrue][,string valueIfFalse]) -Test if current node position is not evenly dividable (modulus) by a given number - - -###.IsEven([string valueIfTrue][,string valueIfFalse]) -Test if current node position is even - -###.IsOdd([string valueIfTrue][,string valueIfFalse]) -Test if current node position is odd - -###.IsEqual(DynamicNode otherNode[,string valueIfTrue][,string valueIfFalse]) -Tests if the current node in your iteration is equivalent (by Id) to another node - -###.IsDescendant(DynamicNode otherNode[,string valueIfTrue][,string valueIfFalse]) -Tests if the current node in your iteration is a descendant of another node - -###.IsDescendantOrSelf(DynamicNode otherNode[,string valueIfTrue][,string valueIfFalse]) -Tests if the current node in your iteration is a descendant of another node or is the node - -###.IsAncestor(DynamicNode otherNode[,string valueIfTrue][,string valueIfFalse]) -Tests if the current node in your iteration is an ancestor of another node - -###.IsAncestorOrSelf(DynamicNode otherNode[,string valueIfTrue][,string valueIfFalse]) -Tests if the current node in your iteration is an ancestor of another node or is the node \ No newline at end of file diff --git a/OurUmbraco.Site/Documentation/master/Reference/Querying/DynamicNode/Library.md b/OurUmbraco.Site/Documentation/master/Reference/Querying/DynamicNode/Library.md deleted file mode 100644 index 46dee183..00000000 --- a/OurUmbraco.Site/Documentation/master/Reference/Querying/DynamicNode/Library.md +++ /dev/null @@ -1,135 +0,0 @@ -#DynamicNode - -##Library -The @Library class is of type RazorLibraryCore in the namespace umbraco.MacroEngines.Library. It contains a collection of useful methods for use in Razor templates. - -###.Coalesce(params object[] args) -Takes the first non-null, non-DynamicNull property value and return the value of it. - - @Library.Coalesce(@Model.property1, @Model.property2, @Model.Name) - -###.Concatenate(params object[] args) - -Concatenate will just concatenate the parameters you pass in together as if you had gone @Model.property + @Model.property2 + @ Model.Name - - @Library.Concatenate(@Model.property1, @Model.property2, @Model.Name) - -###.Join(string seperator, params object[] args) -Join does the same as concatenate except it takes a seperator as the first parameter. - - @Library.Join(",", @Model.property1, @Model.property2, @Model.Name) - -###.NodeById(int Id) -Returns a single node as DynamicNode - -Overloads: - - public dynamic NodeById(int Id) - public dynamic NodeById(string Id) - public dynamic NodeById(object Id) - - -###.NodesById(List