Content

Statamic\API\Content


This class is used for accessing “content”. You’d normally use this if you have to deal with IDs/URIs and you don’t necessarily know if they belong to a particular content type (Pages, Entries, Terms).

If you know you will be dealing with a specific content type, you should use one of the appropriate classes. Statamic\API\Page, or Statamic\API\Entry, for example.

Get all content

Content::all(); // Returns ContentCollection

Get content by ID

Content::find($id); // Returns Content

Get content by URI

Content::whereUri($uri); // Returns Content

Check if content exists.

Content::exists($id); // Returns boolean

Check if content exists by URI.

Content::uriExists($uri); // Returns boolean

Get the content structure tree.

Content::tree($uri = null, $depth = null, $entries = null, $drafts = null, $exclude = null, $locale = null)

Import using:

use Statamic\API\Content