Statamic v2 Documentation

website·Indexed 40 days ago

https://v2.statamic.com/

Documentation for Statamic v2, featuring a comprehensive reference for events used to decouple addons and modify core functionality. Includes details on data events for pages, entries, assets, users, and taxonomies, as well as guides on using controllers to create JSON feeds.

Tokens
115.3K
Snippets
881
Records
1.1K
Agent score
59%

What's inside Statamic

  1. Overview of Statamic Addons

    Addons are the primary mechanism for extending Statamic's core functionality without modifying core files. They allow developers to build new features that are compatible across installations and can be shared or sold. Each addon should ideally solve one clear problem or provide a specific group of related features.
  2. Overview of Statamic AssetContainer

    The Statamic\API\AssetContainer class represents the source where a set of assets and folders are located. It is distinct from AssetCollection, which is a collection of Asset objects.
    use Statamic\API\AssetContainer;
  3. Overview of the Bard fieldtype

    Bard is a rich text editor and layout designer that allows users to mix standard text with custom blocks of fields. It stores structured data and is 100% compatible with the Replicator data structure. It produces clean HTML by restricting tags to a basic set and stripping out unsupported elements.
  4. Overview of Statamic DataCollection

    The Statamic\Data\DataCollection class is used to hold a collection of Data objects, such as Page, Entry, Asset, and User. It inherits from Illuminate\Support\Collection, meaning it supports all standard Laravel collection methods in addition to Statamic-specific functionality.
    use Statamic\Data\DataCollection;
    
    // Create a DataCollection
    $collection = collect_data([1, 2, 3]);
  5. Overview of Statamic Fieldtypes

    Fieldtypes are specialized form inputs used to manage content and data in the Statamic control panel. They are reusable across all Content Types and consist of two main parts: a Vue.js component for the UI and a PHP class for data pre/post processing. Note that Statamic v2 uses Vue.js v1.
  6. Understand Statamic Collections

    Collections are groups of Entries that share the same data structure (Fieldset). Unlike Pages, which are typically unique, Entries in a collection are designed to be similar (e.g., blog posts, news articles). Collections are stored in site/content/collections, with each collection residing in its own subfolder. Entries typically use a filename format consisting of a date or numerical order key and a slug, such as 2015-12-24.christmas-eve.md.
  7. Understand Statamic's core filesystems

    Statamic uses several self-contained filesystems (powered by Flysystem) to allow different types of application data to be stored in different physical locations on a disk. There are 5 core filesystems:

    • Content: Stores site content (default root: site/content).
    • Storage: Stores application storage data (default root: site/storage).
    • Users: Stores user data (default root: site/users).
    • Themes: Stores theme files (default root: site/themes). This filesystem includes a url value to allow browser access to stylesheets and assets.
    • Asset Containers: Each asset container has its own filesystem, allowing them to be stored on local disk or remote services like S3.
    • Server: Used for non-moveable application files and settings. Its root is always the folder above the statamic directory.
  8. Use PageCollection to manage sets of Page objects

    The Statamic\Data\Pages\PagesCollection class is used to hold and manage a collection of Page objects. It inherits from ContentCollection, DataCollection, and Illuminate\Support\Collection, meaning it supports all standard Laravel collection methods.
    use Statamic\Data\Pages\PagesCollection;
  9. Retrieve a page folder by its handle

    Retrieve a specific PageFolder using its handle. The handle corresponds to the path of the folder, for example: pages/1.about/folder.yaml.
    $folder = PageFolder::whereHandle($handle); // Returns PageFolder
  10. Update file and folder naming conventions for Statamic v2

    Statamic v2 introduces strict naming conventions for files and folders:

    • Order Keys: Filename order keys must always be delimited with a period before the slug (e.g., 2015-12-25.christmas.md or 2.about/index.md).
    • Index Files: Rename all page.md files to index.md.
    • Folder Structure: Convert pages not using the folder/index.md format to that format (e.g., /about/team.md must become /about/team/index.md).
  11. Use the YAML fieldtype to store raw data

    The YAML fieldtype provides a code editor set to YAML mode, allowing users to write and store raw data as YAML. It functions similarly to a Textarea fieldtype but ensures the content is saved as YAML rather than a simple string.
  12. Organize publish forms using the Section fieldtype

    The Section fieldtype is used to create visual breaks and section headers within a Statamic publish form. It allows developers to group related fields together, improving the organization and usability of the form for content managers.