Pre-1.0. Not intended for public use yet. The API is subject to undocumented change, and these pages may already be wrong about it.

Skip to content

Activity Content ​

Introduction ​

A body adds structured content beneath an entity’s label: a quote, a photo, a few labelled values. Choose a body from the evidence you have:

EvidenceBody
page with a share previewMediaObject card with the title, description, and image from its preview metadata
passage from a sourceExcerpt
photoImage
a few labelled valuesKeyValue
nothing to addno body; the headline alone

Put supporting detail in the body rather than a headline closure.

Adding Entity Bodies ​

A body contains an entity's structured content. Define it in the model's toFeed method and render it in your frontend. The body is available wherever the entity appears. With InteractsWithFeed, saving the model refreshes its shared snapshot while recording is enabled. That can change the body shown on older activities too. Use activity data to capture values as they were at the event. A composed feed reads toFeed() each time it is read instead.

Every entity in the payload carries its own bodies, in any role. An activity's featured key names the role it features, the object by default. To feature another role's entity, see Featuring Another Role.

Text and Labelled Values ​

app/Models/Order.php
php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Storyfeed\Concerns\InteractsWithFeed;
use Storyfeed\Contracts\Feedable;
use Storyfeed\Body\Prose;
use Storyfeed\FeedEntity;

class Order extends Model implements Feedable
{
    use InteractsWithFeed;

    public function toFeed(): FeedEntity
    {
        return FeedEntity::make()
            ->label("Order #{$this->reference}")
            ->body(
                Prose::make()
                    ->content($this->instructions)
                    ->title("Order #{$this->reference} instructions"),
            );
    }
}
php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Storyfeed\Concerns\InteractsWithFeed;
use Storyfeed\Contracts\Feedable;
use Storyfeed\Body\Prose;
use Storyfeed\FeedEntity;

class Order extends Model implements Feedable
{
    use InteractsWithFeed;

    public function toFeed(): FeedEntity
    {
        return FeedEntity::make(
            label: "Order #{$this->reference}",
            body: Prose::make(
                content: $this->instructions,
                title: "Order #{$this->reference} instructions",
            ),
        );
    }
}
Steve Harrington
Order #1035 instructions

A spoon with the order, please.

Include a title to identify the order when the body appears without a headline.

Use KeyValue for labelled values:

app/Models/Order.phptoFeed()
php
use Storyfeed\Body\KeyValue;
use Storyfeed\FeedEntity;

FeedEntity::make()
    ->label("Order #{$this->reference}")
    ->body(
        KeyValue::make()->title("Order #{$this->reference}")->items([
            'Pickup' => $this->pickup_at->format('g:i a'),
            'Items' => $this->items->count(),
            'Reference' => KeyValue::verbatim($this->reference),
            'Table' => KeyValue::placeholder($this->table, 'not seated'),
        ]),
    );
php
use Storyfeed\Body\KeyValue;
use Storyfeed\FeedEntity;

FeedEntity::make(
    label: "Order #{$this->reference}",
    body: KeyValue::make(
        title: "Order #{$this->reference}",
        items: [
            'Pickup' => $this->pickup_at->format('g:i a'),
            'Items' => $this->items->count(),
            'Reference' => KeyValue::verbatim($this->reference),
            'Table' => KeyValue::placeholder($this->table, 'not seated'),
        ],
    ),
);
Steve Harrington
Order #1035
Pickup
12:10 pm
Items
1
Reference
1035
Table
not seated

Use the KeyValue::placeholder method to specify text for an empty value. Use ->defaultPlaceholder('—') to set the default for every row without its own placeholder, or pass defaultPlaceholder: to KeyValue::make(). The KeyValue::verbatim method marks a value for display without formatting, such as a reference number.

disclosure() gives optional details a label:

php
KeyValue::make(['Reference' => 'R-1042'])->disclosure('Request details');

The label travels as disclosure; blank or null omits it. All rows remain in the payload, so authorize them before recording. Older renderers may show the rows without collapsing them.

Formatted Text and Raw Output ​

For code or raw output, create the body with Prose::verbatim. The body stores the text exactly as given, with verbatim set to true:

app/Models/FieldRecord.phptoFeed()
php
use Storyfeed\Body\Prose;

Prose::verbatim($this->output, title: $this->name);
BN
Bob Newby wrote Hawkins Lab door override
Hawkins Lab door override
10 REM DOOR OVERRIDE — ILLUSTRATIVE BASIC
20 INPUT "SECURITY CODE"; C$
30 IF C$ = "" THEN GOTO 20
40 PRINT "MANUAL OVERRIDE REQUESTED"
50 FOR D = 1 TO 4
60 PRINT "DOOR"; D; " RELEASE REQUEST SENT"
70 NEXT D
80 END
Hawkins Lab lock status was printed at Hawkins Lab
Hawkins Lab lock status
SYSTEM RESTART ........ COMPLETE
MANUAL INPUT .......... ACCEPTED
DOOR CONTROL .......... ONLINE
EXIT LOCKS ............ RELEASED
Dustin Henderson
Dustin Henderson wrote Cerebro reception log
Cerebro reception log
STATION: CEREBRO / WEATHERTOP
CALL TO UTAH .......... NO REPLY
UNEXPECTED SIGNAL .... VOICE / RUSSIAN
MESSAGE .............. REPEATING
NEXT STEP ............ KEEP THE TAPE

To name the code's language, use Prose::code with a media type, such as text/x-php or application/json:

A model's toFeed() method
php
use Storyfeed\Body\Prose;

Prose::code($this->source, 'text/x-php', title: $this->path);

The body stores the media type with the source, as verbatim text.

For formatted text, use Prose::markdown or Prose::html. Storyfeed stores the source as written, with text/markdown or text/html as its media type:

app/Models/FieldRecord.phptoFeed()
php
use Storyfeed\Body\Prose;

Prose::markdown($this->notes, title: $this->title);
Murray Bauman
Murray Bauman wrote Murray’s gate investigation
Murray’s gate investigation

What the machine needs

Alexei’s account: the machine is opening a gate beneath the mall.

  • Locate the control room.
  • Reach the two shutdown keys.
  • Check the safe combination before going in.

Working note: translation is evidence, not a complete floor plan.

Hawkins Lab system report was printed at Hawkins Lab
Hawkins Lab system report

Door control restored. The restart has returned the locks to manual control.

  • Keep the exit route clear.
  • Confirm that everyone has left the building.

Code and Callouts ​

Code carries source text with an optional highlighter language:

php
use Storyfeed\Body\Code;

Code::make('SELECT 1')->language('sql')->title('Health check');

Callout carries a short note with an app-defined intent, defaulting to note:

php
use Storyfeed\Body\Callout;

Callout::make('Pickup closes at 4 pm.')->title('Today')->intent('warning');

Both use their title as the fallback line when set; otherwise Code uses the first source line and Callout uses its content.

Adding Quoted Text ​

Use an Excerpt body for someone's words or a passage from a document. Leave out from when the headline already says who said it; add it when the passage comes from someone or somewhere the headline does not name. Define the body on the quoted model in toFeed():

app/Models/Note.php
php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Storyfeed\Body\Excerpt;
use Storyfeed\Concerns\InteractsWithFeed;
use Storyfeed\Contracts\Feedable;
use Storyfeed\FeedEntity;

class Note extends Model implements Feedable
{
    use InteractsWithFeed;

    public function toFeed(): FeedEntity
    {
        return FeedEntity::make()
            ->label('Order note')
            ->body(
                Excerpt::make()->text($this->body),
            );
    }
}
php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Storyfeed\Body\Excerpt;
use Storyfeed\Concerns\InteractsWithFeed;
use Storyfeed\Contracts\Feedable;
use Storyfeed\FeedEntity;

class Note extends Model implements Feedable
{
    use InteractsWithFeed;

    public function toFeed(): FeedEntity
    {
        return FeedEntity::make(
            label: 'Order note',
            body: Excerpt::make(text: $this->body),
        );
    }
}

The headline names the note's author, so the quotation needs no separate attribution:

Erica Sinclair
Erica Sinclair sent a note about Order #1035
Can I collect this at the counter?

Record the note as the activity's object and the order as its target:

app/Http/Controllers/OrderNoteController.php
php
<?php

namespace App\Http\Controllers;

use App\Models\Order;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Storyfeed\Facades\Storyfeed;

class OrderNoteController extends Controller
{
    public function store(Request $request, Order $order): RedirectResponse
    {
        $note = $order->notes()->create(
            $request->validate(['body' => ['required', 'string']]),
        );

        Storyfeed::activity()
            ->by($request->user())
            ->action('post', $note)
            ->to($order)
            ->publish();

        return back();
    }
}
php
<?php

namespace App\Http\Controllers;

use App\Models\Order;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Storyfeed\Facades\Storyfeed;

class OrderNoteController extends Controller
{
    public function store(Request $request, Order $order): RedirectResponse
    {
        $note = $order->notes()->create(
            $request->validate(['body' => ['required', 'string']]),
        );

        Storyfeed::record(
            verb: 'post',
            object: $note,
            actor: $request->user(),
            target: $order,
        );

        return back();
    }
}

Attributing a Source ​

Use Excerpt to quote someone else's words, such as a person interviewed for a story. Here the headline names the article, and from names the source of the quoted passage:

app/Models/Article.phptoFeed()
php
use Storyfeed\Body\Excerpt;
use Storyfeed\FeedEntity;

FeedEntity::make()
    ->label($this->title)
    ->body(
        Excerpt::make()
            ->text($this->pull_quote)
            ->from($this->pull_quote_source),
    );
php
use Storyfeed\Body\Excerpt;
use Storyfeed\FeedEntity;

FeedEntity::make(
    label: $this->title,
    body: Excerpt::make(
        text: $this->pull_quote,
        from: $this->pull_quote_source,
    ),
);
NW
They came back every night for my fertilizer, bag after bag
Doris Driscoll

Excerpts are complete by default. Call truncated() when you cut the text, and the kits mark the cut. For the entity's own text, such as an article's opening paragraph, use Prose instead.

A record of an answer taken down word for word quotes the person who gave it:

app/Models/FieldRecord.phptoFeed()
php
use Storyfeed\Body\Excerpt;
use Storyfeed\FeedEntity;

FeedEntity::make()
    ->label($this->title)
    ->body(
        Excerpt::make()
            ->text($this->answer)
            ->from($this->answered_by),
    );
php
use Storyfeed\Body\Excerpt;
use Storyfeed\FeedEntity;

FeedEntity::make(
    label: $this->title,
    body: Excerpt::make(
        text: $this->answer,
        from: $this->answered_by,
    ),
);
Dustin Henderson
Dustin Henderson wrote Planck’s constant
Planck’s constant is 6.62607004.
Suzie, over Cerebro

Adding an Image ​

Use an Image body to show a photograph with a caption. Pass the picture's URL to make:

app/Models/Photo.phptoFeed()
php
use Storyfeed\Body\Image;
use Storyfeed\FeedEntity;

return FeedEntity::make()
    ->label($this->name)
    ->body(
        Image::make($this->url)
            ->width($this->width)
            ->height($this->height)
            ->alt($this->description)
            ->caption($this->subject)
    );
php
use Storyfeed\Body\Image;
use Storyfeed\FeedEntity;

return FeedEntity::make(
    label: $this->name,
    body: Image::make(
        image: $this->url,
        width: $this->width,
        height: $this->height,
        alt: $this->description,
        caption: $this->subject,
    ),
);
Steve Harrington
USS Butterscotch
USS Butterscotch

The body stores the URL, so it keeps showing that address. You may also pass a FeedImage, whose alt, width and height become the body's.

For a URL that changes, such as a signed link, pass one of the model's feedMedia() picture slots instead, such as $this->feedMediaPreview(). The body stores the slot's name, and Feed Media resolves the picture each time the feed is read.

size() chooses the picture's presentation:

php
Image::make('/photos/88.jpg')->size('card');

The value travels in $meta.size: thumbnail, inline, card, feature or full. Omit it to use the kit's feed default, or full when no default is set. Explicit full overrides the feed default. Kits choose the lengths and keep pictures uncropped.

Attaching a File ​

A FileAttachment body describes a file, such as a signed agreement's PDF: its name, size and media type. Linking Files shows a Document model that attaches one and links the download.

Listing Items ​

Use ItemList for an order's items. Each item may be a plain string or a FeedLink to another page:

app/Models/Order.phptoFeed()
php
use App\Models\OrderLine;
use Storyfeed\Body\ItemList;
use Storyfeed\FeedEntity;
use Storyfeed\FeedLink;

FeedEntity::make()
    ->label("Order #{$this->reference}")
    ->body(
        ItemList::make()
            ->title("Order #{$this->reference} items")
            ->items(
                $this->lines->take(2)->map(
                    fn (OrderLine $line) => FeedLink::make(
                        $line->item->name,
                        $line->item->url,
                    ),
                ),
            )
            ->items([$this->lines->get(2)->item->name])
            ->totalItems($this->lines->count())
            ->more(FeedLink::make("Order #{$this->reference}", $this->url)),
    );
php
use App\Models\OrderLine;
use Storyfeed\Body\ItemList;
use Storyfeed\FeedEntity;
use Storyfeed\FeedLink;

FeedEntity::make(
    label: "Order #{$this->reference}",
    body: ItemList::make(
        title: "Order #{$this->reference} items",
        items: [
            ...$this->lines->take(2)->map(
                fn (OrderLine $line) => FeedLink::make(
                    $line->item->name,
                    $line->item->url,
                ),
            ),
            $this->lines->get(2)->item->name,
        ],
        totalItems: $this->lines->count(),
        more: FeedLink::make("Order #{$this->reference}", $this->url),
    ),
);
Karen Wheeler
Order #1042 items
and 2 moreOrder #1042

totalItems records the full count and more links to the rest. Use ItemList::ordered() when the sequence of the items matters.

Adding a Table ​

Use Table for rows and columns. Its arguments follow Artisan's $this->table($headers, $rows):

app/Models/Order.phptoFeed()
php
use App\Models\OrderLine;
use Illuminate\Support\Number;
use Storyfeed\Body\Table;
use Storyfeed\FeedEntity;

FeedEntity::make()
    ->label("Order #{$this->reference}")
    ->body(
        Table::make()
            ->headers(['Item', 'Qty', 'Price'])
            ->rows($this->lines->map(fn (OrderLine $line) => [
                $line->item->name,
                $line->quantity,
                Number::currency($line->total),
            ]))
            ->footer(['Total', null, Number::currency($this->total)]),
    );
php
use App\Models\OrderLine;
use Illuminate\Support\Number;
use Storyfeed\Body\Table;
use Storyfeed\FeedEntity;

FeedEntity::make(
    label: "Order #{$this->reference}",
    body: Table::make(
        headers: ['Item', 'Qty', 'Price'],
        rows: $this->lines->map(fn (OrderLine $line) => [
            $line->item->name,
            $line->quantity,
            Number::currency($line->total),
        ]),
    )->footer(['Total', null, Number::currency($this->total)]),
);
Karen Wheeler
ItemQtyPrice
Hot dog2$3.00
Corn dog1$1.75
Pretzel2$4.00
Total—$8.75

A cell is a string, a number, null for an empty cell, or a FeedLink. Format amounts before adding them. footer appends a row beneath the others, such as a subtotal or a total, and title adds a line above the table.

Adding Multiple Bodies ​

Entities in any role can have bodies. Your frontend chooses which to display. Each body() call appends a body in the order given:

app/Models/MenuItem.php
php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Storyfeed\Body\KeyValue;
use Storyfeed\Body\Prose;
use Storyfeed\Concerns\InteractsWithFeed;
use Storyfeed\Contracts\Feedable;
use Storyfeed\FeedEntity;

class MenuItem extends Model implements Feedable
{
    use InteractsWithFeed;

    public function toFeed(): FeedEntity
    {
        return FeedEntity::make()
            ->label($this->name)
            ->body(Prose::make($this->description))
            ->body(KeyValue::make()->items('Station', $this->station));
    }
}
php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Storyfeed\Body\KeyValue;
use Storyfeed\Body\Prose;
use Storyfeed\Concerns\InteractsWithFeed;
use Storyfeed\Contracts\Feedable;
use Storyfeed\FeedEntity;

class MenuItem extends Model implements Feedable
{
    use InteractsWithFeed;

    public function toFeed(): FeedEntity
    {
        return FeedEntity::make(
            label: $this->name,
            body: [
                Prose::make($this->description),
                KeyValue::make(items: ['Station' => $this->station]),
            ],
        );
    }
}
Steve Harrington

Two scoops with warm sauce.

Station
Fountain

Linking a Title ​

Use MediaObject for a notice with a title and a short description. Pass a FeedLink as its subject to make the title a link:

app/Models/Notice.phptoFeed()
php
use Storyfeed\Body\MediaObject;
use Storyfeed\FeedEntity;
use Storyfeed\FeedLink;

FeedEntity::make()
    ->label($this->title)
    ->body(
        MediaObject::make()
            ->subject(FeedLink::make($this->title, $this->url))
            ->content($this->description),
    );
php
use Storyfeed\Body\MediaObject;
use Storyfeed\FeedEntity;
use Storyfeed\FeedLink;

FeedEntity::make(
    label: $this->title,
    body: MediaObject::make(
        subject: FeedLink::make($this->title, $this->url),
        content: $this->description,
    ),
);
Steve Harrington

Scoops Ahoy opening hours

The counter opens at 10 am. Orders are available until 9 pm.

The title links to the notice at the URL supplied when its body is stored.

To link to another page, pass that page's title and URL:

app/Models/Notice.phptoFeed()
php
use Storyfeed\Body\MediaObject;
use Storyfeed\FeedEntity;
use Storyfeed\FeedLink;

FeedEntity::make()
    ->label($this->title)
    ->body(
        MediaObject::make()
            ->subject(FeedLink::make($this->guide_title, $this->guide_url))
            ->content($this->description),
    );
php
use Storyfeed\Body\MediaObject;
use Storyfeed\FeedEntity;
use Storyfeed\FeedLink;

FeedEntity::make(
    label: $this->title,
    body: MediaObject::make(
        subject: FeedLink::make($this->guide_title, $this->guide_url),
        content: $this->description,
    ),
);
Steve Harrington

Starcourt Mall visitor guide

The visitor guide includes entrances, parking and shop locations.

A plain-string subject stores a title without a link.

Adding a Call to Action ​

Use CallToAction for a sentence or two and one action. The action's text says what to do, and FeedLink::toEntity() sends it to the entity the body belongs to:

app/Models/Notice.phptoFeed()
php
use Storyfeed\Body\CallToAction;
use Storyfeed\FeedEntity;
use Storyfeed\FeedLink;

FeedEntity::make()
    ->label($this->title)
    ->body(
        CallToAction::make()
            ->content($this->description)
            ->action('Read the notice', FeedLink::toEntity()),
    );
php
use Storyfeed\Body\CallToAction;
use Storyfeed\FeedEntity;
use Storyfeed\FeedLink;

FeedEntity::make(
    label: $this->title,
    body: CallToAction::make(
        content: $this->description,
    )->action('Read the notice', FeedLink::toEntity()),
);
Steve Harrington

The counter opens at 10 am. Orders are available until 9 pm.

Read the notice

subject adds a short heading. The action is required, and a string in place of the FeedLink is a plain link.

A FeedLink contains a label and an href. Pass the destination URL as the second argument to FeedLink::make, or set it with the href method. FeedLink::toEntity() stores no URL: the renderer links it to the entity's own link each time the feed is read.

The href is stored as written. It can become stale if a route changes or a signed URL expires.

The label names the thing, such as a notice or an order. See the FeedLink reference for its methods and the body fields that accept it.

Setting a Body's Height ​

A body may tell the renderer how tall to draw it. maxHeight takes a CSS length, and fullHeight shows the whole body:

app/Models/Order.phptoFeed()
php
use Storyfeed\Body\Prose;
use Storyfeed\Body\Table;
use Storyfeed\FeedEntity;

return FeedEntity::make()
    ->label("Order #{$this->reference}")
    ->body(
        Prose::markdown($this->notes)->fullHeight(),
        Table::make(['Item', 'Qty'], $this->summary)->maxHeight('16rem'),
    );

Both write the body's $meta.maxHeight. Add your own renderer settings with withMeta, using a dotted key such as acme.layout:

app/Models/Order.phptoFeed()
php
use Storyfeed\Body\Prose;

Prose::markdown($this->notes)->withMeta(['acme.layout' => 'wide']);

Adding a Fallback Line ​

Every body accepts a fallback: one line of plain text, stored in the body's $fallback key, for a renderer that does not draw its type:

app/Models/Order.phptoFeed()
php
use Storyfeed\Body\KeyValue;
use Storyfeed\FeedEntity;

return FeedEntity::make()
    ->label("Order #{$this->reference}")
    ->body(
        KeyValue::make()
            ->items('Pickup', $this->pickup_at->format('g:i a'))
            ->fallback("Pickup at {$this->pickup_at->format('g:i a')}"),
    );
php
use Storyfeed\Body\KeyValue;
use Storyfeed\FeedEntity;

return FeedEntity::make(
    label: "Order #{$this->reference}",
    body: KeyValue::make(
        items: ['Pickup' => $this->pickup_at->format('g:i a')],
    )->fallback("Pickup at {$this->pickup_at->format('g:i a')}"),
);
[
  {
    "kind": "activity",
    "id": "a-confirm",
    "verb": "confirm",
    "published_at": "1985-07-02T12:03:00.000000Z",
    "starts_at": null,
    "ends_at": null,
    "headline_template": ":actor confirmed :object",
    "headline": null,
    "bindings": null,
    "glyph": "circle-check",
    "glyph_intent": null,
    "actor": {
      "type": "user",
      "id": "101",
      "label": "Steve Harrington",
      "link": {
        "href": "/users/101",
        "modal": false,
        "attributes": []
      },
      "data": [],
      "media": {
        "icon": {
          "src": "/media/worlds/stranger-things/avatars/scooper.jpg",
          "mediaType": "image/jpeg",
          "width": 256,
          "height": 256,
          "alt": null
        },
        "image": null,
        "preview": null,
        "initials": null,
        "color": null,
        "files": [],
        "slots": []
      },
      "media_ref": "md08aeb0f13f95241",
      "entity_ref": "e6b153676d8dbc853",
      "body": null,
      "tombstone": null
    },
    "object": {
      "type": "order",
      "id": "1035",
      "label": "Order #1035",
      "link": {
        "href": "/orders/1035",
        "modal": false,
        "attributes": []
      },
      "data": [],
      "media": {
        "icon": null,
        "image": null,
        "preview": null,
        "initials": "O1",
        "color": "#4d7c0f",
        "files": [],
        "slots": []
      },
      "media_ref": "ma9527581042280f7",
      "entity_ref": "e722f0b114fd1ec13",
      "body": [
        {
          "$body": "Storyfeed/Body/KeyValue",
          "$v": 3,
          "$fallback": "Pickup at 12:10 pm",
          "items": [
            {
              "key": "Pickup",
              "value": "12:10 pm"
            }
          ]
        }
      ],
      "tombstone": null
    },
    "target": {
      "type": "venue",
      "id": "101",
      "label": "Scoops Ahoy",
      "link": {
        "href": "/venues/scoops",
        "modal": false,
        "attributes": []
      },
      "data": [],
      "media": {
        "icon": null,
        "image": null,
        "preview": {
          "src": "/media/worlds/stranger-things/parlour.jpg",
          "mediaType": "image/jpeg",
          "width": 960,
          "height": 720,
          "alt": "An ice cream counter"
        },
        "initials": "SA",
        "color": "#9f1239",
        "files": [],
        "slots": []
      },
      "media_ref": "m1bcad7c79ddfc05d",
      "entity_ref": "e352bb6f37b7d8bfe",
      "body": [
        {
          "$body": "Storyfeed/Body/Image",
          "$v": 3,
          "alt": "Scoops Ahoy",
          "caption": "Scoops Ahoy",
          "image": "preview"
        }
      ],
      "tombstone": null
    },
    "context": null,
    "origin": null,
    "result": null,
    "instrument": null,
    "location": null,
    "generator": null,
    "featured": "object",
    "data": null,
    "tombstoned": [],
    "redundant": false,
    "missing_headline_template": null,
    "missing_headline": null
  }
]

Without one, a Table stores its title and a CallToAction its subject or action text as the fallback. Other body types store none.

Available Body Types ​

Body TypeContentPayload KeysLeft Out at Their Default
KeyValuelabelled valuestitle, defaultPlaceholder, disclosure, items[] of key, value, verbatim, placeholdertitle, defaultPlaceholder, disclosure; a row's verbatim (false) and placeholder (the body's defaultPlaceholder)
Excerpta quoted passage with optional source attributiontext, from, truncatedfrom, truncated (false)
Imagea picture and captionsrc, mediaType, caption, alt, width, height, image (slot name)all
FileAttachmentfile name, size, and media typename, size, mediaTypeall
Prosetext and its formatcontent, mediaType, verbatim, titlemediaType (text/plain), verbatim (false), title
ItemListnamed items with optional linkstitle, items[], ordered, totalItems, moretitle, ordered (false), totalItems, more
MediaObjecta title, text, image, and filessubject, content, image, files, footnotesubject, content, image, files ([]), footnote
Tablerows and columnstitle, headers, rows, footertitle, headers ([]), footer ([])
CallToActiona heading, text, and one actionsubject, content, action of label, linksubject, content
Componenta custom component name and propsname, propsprops ([])
Codesource text and an optional languagetitle, language, sourcetitle, language
Callouta short note with an intenttitle, content, intenttitle, intent (note)

A stored body leaves out each key that holds its default, which is null unless the table says otherwise. A body class's static upgrade($payload, $from) method takes a stored payload and its $v, and returns it with every key filled in.

These classes use the Storyfeed\Body namespace. Each body's payload includes its type in $body, such as Storyfeed/Body/KeyValue, and its version in $v. Your renderer uses these fields to display the body. A body may also carry $meta, its renderer settings. Passing a string as a body creates a Prose body.

See Resolving Bodies When Retrieved for current and deferred values, or Custom Body Types to render custom components and define your own body types.

To feature a role other than the object, see Featuring Another Role.

Released under the MIT License.