Skip to content

Commit

Permalink
Clean set/get API
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Oct 10, 2023
1 parent 84e27f0 commit 2f6f8fc
Show file tree
Hide file tree
Showing 4 changed files with 288 additions and 226 deletions.
16 changes: 8 additions & 8 deletions docs/MetaHelper.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ $this->set(compact('_meta')));

In your view ctp you can also do:
```php
$this->Meta->keywords('I, am, English', 'en');
$this->Meta->keywords('Ich, bin, deutsch', 'de');
$this->Meta->description('Foo Bar');
$this->Meta->robots(['index' => false]);
$this->Meta->setKeywords('I, am, English', 'en');
$this->Meta->setKeywords('Ich, bin, deutsch', 'de');
$this->Meta->setDescription('Foo Bar');
$this->Meta->setRobots(['index' => false]);
```
By default this will not output anything, but collect it inside the helper.
All this data will be collected it inside the helper across teh whole request.
Those calls can be best made in a view or element (because those are rendered before the layout).
If you do it inside a layout make sure this happens before you call `out()`.

Expand All @@ -63,11 +63,11 @@ echo $this->fetch('meta'); // This is a fallback (optional) for view blocks
It will iterate over all defined meta tags and output them.
Note that you can skip some of those, if you want using the `skip` option.

If you don't manually outputting them, you must define all tags prior to the `out()` call.
If you don't manually output them, you must define all tags prior to the `out()` call.
The `out()` call should be the last PHP code in your `<head></head>` section the layout HTML.

You can also manually output each group of meta tags, e.g. all keywords and descriptions (which you defined before) in all languages using
```php
echo $this->Meta->keywords();
echo $this->Meta->description();
echo $this->Meta->getKeywords();
echo $this->Meta->getDescription();
```
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
## Contributing
Your help is greatly appreciated.

Make sure tests pass: `php phpunit.phar`
Make sure tests pass: `composer test`

Make sure CS pass: `vendor/bin/sniff` and `vendor/bin/sniff -f` to auto-fix
Make sure CS pass: `composer cs-check` and `composer cs-fix` to auto-fix
Loading

0 comments on commit 2f6f8fc

Please sign in to comment.