Statistics
53
1
0
64d
Badges
Dependencies

Meta Control

Build Status Coverage Status Downloads this Month Latest stable

Installation

Via Composer:

$ composer require nepada/meta-control

Usage

First register the control factory in your config and optionally set up default metadata:

services:
    -
        implement: Nepada\MetaControl\IMetaControlFactory
        setup:
            - setCharset('utf-8')
            - setAuthor('Jon Doe')

Use the control factory in your presenter:

protected function createComponentMeta(): Nepada\MetaControl\MetaControl
{
    $control = $this->metaControlFactory->create();
    $control->setDescription('Lorem ipsum');
    return $control;
}

And render it in your Latte template:

<html>
<head>
    {control meta}
</head>
<body>
    ...
</body>
</html>

Overview of supported meta tags

Charset:

// <meta charset="utf-8">
$control->setCharset('utf-8');
$control->getCharset(); // 'utf-8'

Document metadata:

// <meta name="author" content="John Doe">
$control->setMetadata('author', 'Jon Doe');
$control->getMetadata('author'); // 'Jon Doe'

Document properties:

// <meta property="og:title" content="Foo title">
$control->setProperty('og:title', 'Foo title');
$control->getProperty('og:title'); // 'Foo title'

Pragma directives:

// <meta http-equiv="content-type" content="text/html; charset=UTF-8">
$control->setPragma('content-type', 'text/html; charset=UTF-8');
$control->getPragma('content-type'); // 'text/html; charset=UTF-8'

Shorthands for standard metadata

Author:

// <meta name="author" content="John Doe">
$control->setAuthor('Jon Doe');
$control->getAuthor(); // 'Jon Doe'

Description:

// <meta name="description" content="Lorem ipsum">
$control->setDescription('Lorem ipsum');
$control->getDescription(); // 'Lorem ipsum'

Keywords:

// <meta name="keywords" content="foo, bar, baz">
$control->setKeywords('foo', 'bar');
$control->addKeyword('baz');
$control->getKeywords(); // ['foo', 'bar', 'baz']

Robots:

// <meta name="robots" content="noindex, nofollow">
$control->setRobots('noindex, nofollow');
$control->getRobots(); // 'noindex, nofollow'

No release at this moment. Try to create first one.

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com