PHP helper class for building HTML response.
PHP >= 5.6.0
$page = new \Dtkahl\Page\Page;
add meta data:
$page->meta->set('title', 'foobar');
render meta data (ibnside your template):
<?php echo $page->renderMeta() ?>
supported keys:
- title
- charset
- date
- copyright
- keywords
- viewport
- robots
- page-topic
- page-type
- og:type
- audience
- google-site-verification
- csrf-token
- twitter:site
- twitter:card
- local
- og:site_name
- description
- image
- url
- author
- publisher
- language
- (raw)
With options you can configure the page:
title_pattern
: pattern for meta title. Example:%s | foobar.com
$page->options->set('title_pattern', `%s | foobar.com`);
You can define which files should be loaded.
$page->addJavascript('script'); // ".js" automatically added
$page->addStylesheet('style'); // ".css" automatically added
... and render the includes in your template:
<?php echo $page->renderJavascripts() ?>
<?php echo $page->renderStylesheets() ?>
With sections you have one more way to push information to your view.
Example to pass simple information...
$page->sections->set('foo', 'bar')
In your view you can retrieve the section:
<?php echo $page->sections->get('foo') ?>
Almost like sections, but an area is a collection of multiple items. (Like widgets in a sidebar)
Example:
$page->area('sidebar')->push('bar')
In your view you can iterate over the items of the area:
<?php $page->area('sidebar')->each(function ($widget) {
echo $widget;
});
?>
$page->meta($key)
does the same like$page->meta->get($key)
$page->meta($key, $value)
does the same like$page->meta->set($key, $value)
$page->option($key)
does the same like$page->options->get($key)
$page->option($key, $value)
does the same like$page->options->set($key, $value)
$page->section($key)
does the same like$page->sections->get($key)
$page->section($key, $value)
does the same like$page->sections->set($key, $value)