You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

children

The children keyword returns the child nodes of the current node.

Note: This keyword is only available on Page Elements (DOM nodes).

Search results for "children"

children

The children keyword returns the child nodes of the current node.

Buttons

Icon Action
Clone icon Clone element and all its children
Edit Properties icon Open Properties dialog
Delete icon Delete element and all its children
Unlink icon Remove element and all its children
Key icon Open Access Control and Visibility Dialog
Pencil icon Open Edit Content Dialog
Link icon Open Edit Link Dialog

Rendering the children of a Template Element

${{
// fetch the templates child elements
const children = $.get('children');

// render the child elements
$.render(children);
}}

Content Types

This content type must be set on template elements or content elements that are included using the built-in include() function, and on so-called Main Page Templates that use ${render(<a data-id="3230f1d81eb345c199024b82eb7c56f2" class="mention">children</a>)}.

Template Elements

As defined in the DOM specification, Content Elements must not have child nodes. To be able to mix template expressions and node structures, Structr provides a block-version of Content Elements, the so-called Template Elements (Template icon). Similar to Content Elements, Template Elements support different content types and allow for template expressions. However, in contrast to Content Elements, Template Elements can have children.

Templates

We start by introducing the template element. In Structr, templates are special elements that may be inserted into a page’s DOM tree at any position. Much like a content element, a template element has a body which is rendered into the page. However, in contrast to the content element, a template element may have children in the DOM tree, which will become important later on.

Template Elements

Therefore, the rendering flow stops at template elements and does not render the remaining branch of the DOM tree. Instead, the template element has to explicitly invoke the rendering process for it’s child elements in the appropriate place. To accomplish this, Structr provides the children keyword and the render() function, as shown in the example below. While this makes the configuration of template elements a bit more subtle than that of content elements, it provides much more flexibility.

Types

Each Type contains child elements representing it’s Local Attributes, Remote Attributes, Views, Methods and Inherited Attributes. With the exception of Inherited Attributes, which are read-only, all children provide options to mange their respective content.

Templates

Finally, we create a shared component out of this template element. This allows us to include the template into every new page we create within this project, creating a skeleton for new pages that include the top navigation menu and the footer. Due to the render(<a data-id="3230f1d81eb345c199024b82eb7c56f2" class="mention">children</a>) expression in the template body, the individual content of each new page can then be added as a child of the template in the DOM tree, allowing us to quickly create pages with the same main theme but different content.

Creating a Shared Component

You can create new Shared Components by dragging and dropping an element from the Pages Tree View into the drop area at the top of the Shared Components flyout. When you do that, Structr copies the source element to the Shared Components flyout and moves all its children to the new copy. The source element becomes a so-called “synced node” that relays the rendering process to the Shared Component.

Content of Current Folder

Icon Action
Pencil icon Open File’s content (and dynamic content) dialog
Edit Properties icon Open Properties dialog
Delete icon Delete the File or Folder (with all it’s children)
Key icon Open Access Control and Visibility dialog

Template Elements

Templates

<!-- Page Content-->
${render(children)}