Giter Site home page Giter Site logo

cakephp-meta's Introduction

Meta plugin for CakePHP

CI Coverage Status License Minimum PHP Version Latest Stable Version Coding Standards

This branch is for CakePHP 5.0+. For details see version map.

What is this plugin for?

This plugin helps to maintain and output meta tags for your HTML pages, including SEO relevant parts like "title", "keywords", "description", "robots" and "canonical".

It can be used as a simple view-only approach using the included helper, it can also be DB driven if desired, or dynamically be created from the controller context by passing the meta data to the view.

Installation and Usage

Please see Docs

ToDos

DB driven approach

Adding a Meta component and Metas Table we can pull data from an admin backend inserted DB table. Those could overwrite then any defaults set via actions or ctp templates.

cakephp-meta's People

Contributors

choma avatar dereuromark avatar wyrihaximus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cakephp-meta's Issues

Invalid argument supplied for foreach

As per your configuration documentation, I'm adding meta tags from within action

public function view($title = null)
{
    $contentPage = $this->ContentPages->find()
      ->where(['Categories.title LIKE' => 'Services', 'ContentPages.title LIKE' => $title, 'ContentPages.status' => 0])
      ->contain(['Categories'])
      ->first();

    $_meta = [
        'title' => $contentPage->title,
        'keywords' => $contentPage->meta_keyword,
        'description' => $contentPage->meta_description,
        'author' => 'DigiTechXPro'
    ];
 
    $this->set('contentPage', $contentPage);
    $this->set(compact('_meta'));
    $this->set('_serialize', ['contentPages']);
}

But this is producing error
Warning (2): Invalid argument supplied for foreach() [ROOT/vendor/dereuromark/cakephp-meta/src/View/Helper/MetaHelper.php, line 326]

Edit 2

on debug($_meta) in the action, it gives

[
    'title' => 'SEO Services',
    'keywords' => 'hello, world',
    'description' => 'hello',
    'author' => 'DigiTechXPro'
]

Add feature to add common meta data

  • Suggestion

  • CakePHP : 3.x

Add feature to add common meta data from config file.

Example : metadata.php in config directory may contain

$metadata = [
    ‘_all’ => [
	‘description’ => ‘Site wide description’
    ],
    ‘pages’ => [
   	   ‘_all’ => [
		‘description’ => ‘All pages_controller pages description’,
                'keywords' => ['en' => 'keyword, for, all, pages']
	   ],
	   ‘home’ => [
		‘description’ => ‘Home page description’
	   ]
    ],
    ‘controller_name’ => [
	   ‘_all’ => [
		‘description’ => ‘All controller_name actions description’
	   ],
	   ‘action’ => [
		‘description’ => ‘controller_name/action description’
	   ]
    ]
];

and append all in view on out();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.