Page · Mecha CMS

Working with pages.

$page->data()

Author: Taufik Nurrohman · 19 Views

Tweet

Insert new page data, update and/or remove current page data.

->data($input, $fn = null);

Example:

Set page header:

Page::open('path\to\file.page')->data([
    'title' => 'Page Title',
    'description' => 'Page description.',
    'author' => 'Taufik Nurrohman',
    'type' => 'HTML'
]);
Page::open('path\to\file.page')->data('title', function($data) {
    return $data['author']; // ← set `author` value as the `title`
});

Set page content:

Page::open('path\to\file.page')->data('<p>Page content.</p>');

Remove title data:

Page::open('path\to\file.page')->data(['title' => false]);

Set title data as false:

Page::open('path\to\file.page')->data(['title' => 'false']);

Remove page content:

Page::open('path\to\file.page')->data(false);