Mecha CMS

Mecha CMS blog and documentation.

Class Page

Updated: Sunday, 07 August 2016

Creating a page file with a more convenient way.

Added since version 1.1.3.

Update Page Data

Page::open('page.txt')
    ->header('Title', 'Replace Title')
    ->content('Replace content.')
    ->save();

Set Page Header

Page::header('Title', 'Test Title')->saveTo('page.txt');

Result:

Title: Test Title
Page::header(array(
    'Title' => 'Test Title',
    'Content Type' => 'HTML'
))->saveTo('page.txt');

Result:

Title: Test Title
Content Type: HTML

Set Page Content

Page::header('Title', 'Test Title')
    ->content('Test content.')
    ->saveTo('page.txt');

Result:

Title: Test Title

====

Test content.

Remove Page Header

Page::open('page.txt')
    ->header(array(
        'Title' => false,
        'Content Type' => 'false'
    ))->save();

Result:

Content Type: false

Remove Page Content

Page::open('page.txt')
    ->header('Title', 'Test Title')
    ->content(false)
    ->save();

Result:

Title: Test Title

Page Data Output

$data = Page::header('Title', 'Test Title')
            ->content('Test content.')
            ->read('content', 'page:');

var_dump($data); // test!

Raw Page Data Output

echo Page::header('Title', 'Test Title')
         ->content('Test content.')
         ->put();

Parse Text into Page Array

var_dump(Page::text($source_text));

The page pattern looks like this:

Title: Some Text
Another Title: Another Thing
Another Weir(#$!e)D Page-Field: Ouch!
Boolean: true
Total Comments: 2000

====

Page content **goes** here.

Results:

array(
    'title' => 'Some Text',
    'another_title' => 'Another Thing',
    'another_weir_e_d_page_field' => 'Ouch!',
    'boolean' => true,
    'total_comments' => 2000,
    'content_raw' => 'Page content **goes** here.',
    'content' => '<p>Page content <strong>goes</strong> here.</p>'
);
Donation and Email Subscription