Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/izica/phalcon-meta-tags

Phalcon PHP Meta tags Service
https://github.com/izica/phalcon-meta-tags

meta-tags phalcon phalcon-meta-tags phalcon-php phalcon-php-framework phalconphp php php-library php7 seo seo-friendly seo-manager seo-meta tags

Last synced: 3 months ago
JSON representation

Phalcon PHP Meta tags Service

Awesome Lists containing this project

README

        

# About
Phalcon meta tags plugin for PhalconPHP.

This plugin allows you to easily and flexibly customize the meta tags of your view.

If this plugin helped you, be glad to see your star, thank you.

Check out new validation package for PhalconPHP
https://github.com/izica/phalcon-validation

* [Install](#Install)
* [Plugin functions](#Plugin-functions)
* [Usage](#Usage)
* [Register plugin as service](#Register-plugin-as-service)
* [Add data to your layout](#Add-data-to-your-layout)
* [Use service in controller, view or middleware(anywhere)](#use-service-in-controller-view-or-middlewareanywhere)
* [Example of output](#Example-of-output)

# Install
```bash
composer require izica/phalcon-meta-tags
```

# Plugin functions

```php
setTitle($title)
getTitle()
setByProperty($property, $content)
unsetByProperty($properties) //array or single property name

setByName($name, $content)
unsetByName($properties) //array or single name

setCustom($key, $attributes) //unique key and attributes array
unsetCustom($keys) //array or single value
getMeta() // return metas string
```

# Usage:
## Register plugin as service:
```php
$di = new DI();
$di->set('metatag', function() {
return new IzicaMetaTags();
});
```

## Add data to your layout:
```php



metatag->getTitle();?>
metatag->getMeta();?>


getContent(); ?>


```

## Use service in controller, view or middleware(anywhere):
```php
use Phalcon\Mvc\Controller;

class IndexController extends Controller
{
public function indexAction()
{
$this->metatag->setTitle("Phalcon MetaTags Service");

$this->metatag->setCustom("charset", ['charset' => 'UTF-8']);
$this->metatag->setCustom("http", ['http-equiv' => 'content-type', 'content' => 'text/html; charset=UTF-8']);

$this->metatag->setByName("description", "phalcon php metatags");

$this->metatag->setByProperty("og:description", "When Great Minds Don’t Think Alike");
}
}
```

## Example of output:
```html
Phalcon MetaTags Service




```