Umbraco: differences between Node, DynamicNode, Content

前端 未结 3 634
旧巷少年郎
旧巷少年郎 2021-02-04 17:03

Then there are many class that represents Umbraco documents:

1) umbraco.cms.businesslogic.Content
2) umbraco.cms.businesslogic.web.Document
3) umbraco.MacroEngin         


        
相关标签:
3条回答
  • 2021-02-04 17:40

    Content allows you to retrieve/edit any content (page/media/..) from DB (including non-published content), Document allows you to retrieve/edit only page content from DB (including non-published content), Node is used for fast read-only access to (published only) page content from the XML cache and Dynamic Node is comparable to Node but implemented in later versions of Umbraco for macros using Razor

    0 讨论(0)
  • 2021-02-04 17:41

    I just know the difference between Document and Node. The Node class uses the data stored in the umbraco cache, the Document class will get data directly from the database. Node is faster than Document. Node only returns the content that is saved and published.

    95% of time you should use Node.

    0 讨论(0)
  • 2021-02-04 17:59

    Based on personal use:

    1. Content: Never use it directly, rather use the Document|Media|Member api (which inherits from this class).
    2. Document: Use it for Create|Update|Delete operations. It does all of its operation directly to DB, so it should be used for Reading only when you need to values directly from the db.
    3. Node: Use this most: when Reading|Displaying data through usercontrols, code libraries, xslt extensions, etc.
    4. DynamicNode: Razor macros. I have not yet use this one enough to provide more info.

    See below for more detail, but no, Node and DynamicNode are not the same (DynamicNode uses Examine and will also fall back to reading from the DB if needed).

    umbraco.cms.businesslogic.Content: Content is an intermediate layer between CMSNode and classes which will use generic data. Content is a datastructure that holds generic data defined in its corresponding ContentType. Content can in some sence be compared to a row in a database table, its ContentType holds a definition of the columns and the Content contains the data. Note that Content data in umbraco is not tabular but in a treestructure.

    I have never had the need to use this class directly though, as all of its operations are handled by the corresponding subclass, e.g: Document, Media, Member. This class in turns inherits from CMSNode which is the base class for every piece of content data inside umbraco

    umbraco.cms.businesslogic.web.Document:Document represents a webpage, published Documents are exposed to the runtime/the public website in a cached xml document.

    Use this class when referencing nodes from your "Content Section". It handles CRUD operations. Through this class you also get a reference to the DataType of each property in case you want to render those controls in an aspx page.

    umbraco.NodeFactory.Node: It implements the INode interface which exposes read-only methods. All of its information comes from the umbraco cached xml. You will not get access to the controls of each property, rather the values of each formatted depending on the datatype.

    You can only use this class for reading operations. It makes it really fast to show data since everything comes from cache (published nodes only).

    umbraco.MacroEngines.DynamicNode: It was implemented to work with razor macros. It uses NodeFactory under the hood, which means it also access the cached xml. Although if you use the related DynamicMedia be careful as it uses: 1: ExamineIndex which strips out any html tags, 2: it falls back to its default Media type (db if it isn't in runtime cache) in umbraco_v4.11.5.

    Same as the above.

    0 讨论(0)
提交回复
热议问题