Docs Navigation Open

Resources

Understand how resources are stored, how the tree works, and how SiteContent can be queried in code.

What a Resource Is

In Evolution CMS the main content object is a resource. Older documentation often calls it a document, but in code the model is EvolutionCMS\Models\SiteContent.

A resource usually stores:

  • pagetitle, longtitle, description, introtext, content
  • alias, parent, isfolder, menuindex
  • template, published, cacheable, searchable, hidemenu

How the Tree Works

The resource tree is more than navigation. It affects URLs, manager workflow, listings, breadcrumbs, access rules, and many extras.

  • parent defines the place in the tree.
  • isfolder marks a resource as a container for child resources.
  • menuindex controls order among siblings.
  • alias is used by friendly URLs.
  • hidemenu controls whether the resource should appear in menu output.

Important SiteContent Relations

use EvolutionCMS\Models\SiteContent;

$doc = SiteContent::find(7);
$parent = $doc->ancestor;
$children = $doc->children;
$template = $doc->tpl;
$tvValues = $doc->templateValues;

Querying the Tree

The SiteContent model includes closure-table helpers for tree traversal. This is one of the most important Evo 3 improvements for developers.

use EvolutionCMS\Models\SiteContent;

$rootItems = SiteContent::published()
    ->where('parent', 0)
    ->orderBy('menuindex')
    ->get();

$branch = SiteContent::descendantsOf(2)
    ->where('depth', '<', 4)
    ->get()
    ->toTree()
    ->toArray();

$parents = SiteContent::find(7)
    ->ancestors()
    ->orderBy('depth', 'desc')
    ->get();

Working with TVs on Resources

The old docs mostly explained TVs from the manager side. In Evo 3 you can also query them directly from SiteContent.

$docs = SiteContent::withTVs(['price', 'brand'])
    ->active()
    ->where('parent', 0)
    ->tvFilter('tv:price:>:150:UNSIGNED;tv:brand:!null;')
    ->tvOrderBy('price desc UNSIGNED, brand asc')
    ->get();

For the surrounding element vocabulary, see Terminology. For the underlying model inventory, see Data Model.

Previous

Terminology

Learn the core Evolution CMS terms, parser tags, and the way templates, TVs, chunks, snippets, and plugins work together.

Next

Templates, TVs, and Snippets

See how templates, TVs, chunks, snippets, and plugins divide structure, data, presentation, and logic in real projects.