Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setKeywords returns error: undefined method #76

Closed
ahmadyousefdev opened this issue Oct 7, 2016 · 5 comments
Closed

setKeywords returns error: undefined method #76

ahmadyousefdev opened this issue Oct 7, 2016 · 5 comments

Comments

@ahmadyousefdev
Copy link

Hi ! , first thank you so much for this amazing work,
I ran into an issue , I tried to set the keywords in my controller like this:

// before class
use SEO;

---
// in controller:
SEO::setKeywords('key1', 'key2', 'key3');

but I ran into this error:

Call to undefined method Artesaos\SEOTools\SEOTools::setKeywords()

I tried this code too:

//before class
use Artesaos\SEOTools\Traits\SEOTools as SEOToolsTrait;

---
//after class
use SEOToolsTrait;

---
// in controller:
$this->seo()->setKeywords(['key1', 'key2', 'key3']);

with the same error, Note, those are working fine with no problems:

SEO::setTitle('title');
SEO::setDescription(str_limit($work->description, $limit = 120, $end = '...'));
SEO::opengraph()->addProperty('type', 'articles');
@ahmadyousefdev
Copy link
Author

ahmadyousefdev commented Oct 7, 2016

I tried adding them like this too:

SEO::addMeta('keywords', $work->tags()->pluck('tag')->toArray(), 'name');

and I got the same error but this time for addMeta :

Call to undefined method Artesaos\SEOTools\SEOTools::addMeta()

@edbizarro
Copy link
Contributor

edbizarro commented Oct 7, 2016

try this:

use Artesaos\SEOTools\SEOTools as SEO;
...

SEO::setKeywords('key1, key2, key3');

or using the trait:

$this->seo()->metatags()->setKeywords(['key1', 'key2', 'key3']);

@ahmadyousefdev
Copy link
Author

This made another error for the working ones ( setTitle for example ):

Non-static method Artesaos\SEOTools\SEOTools::setTitle() should not be called statically, assuming $this from incompatible context

I thought it might be conflicted then I used this:

use Artesaos\SEOTools\SEOTools as SEOA;
---
SEOA::setKeywords('key1', 'key2', 'key3');

but it gave me the same error:

Call to undefined method Artesaos\SEOTools\SEOTools::setKeywords()

@edbizarro
Copy link
Contributor

sry, the meta facade have another name, use SEOMeta facade instead

SEOMeta::setKeywords('key1,key2,key3');

and use only one string parameter instead of three (or an array)

Or the trait

$this->seo()->metatags()->setKeywords(['key1', 'key2', 'key3']);

or you could instantiate yourself

$seo = app()->make('seotools.metatags');

$seo->setDescription(['key1', 'key2', 'key3']);

@ahmadyousefdev
Copy link
Author

This is it ! , Thank you so much, so the function called metatags() , this is what I was missing.

SEO::metatags()->setKeywords(['key1', 'key2', 'key3']);

This works perfectly too. Thank you for helping me I really appreciate it. This Package is so helpful ! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants