Jump to content

SeoMaestro


Wanze

Recommended Posts

@3fingers Having said all the above, maybe it is easiest to just disable the tag you are having trouble with and add it manually? Or for that template render out each one individually and build the image tag yourself. This is Processwire’s only issue, for every problem there are a million solutions!!!! 

  • Like 1
Link to comment
Share on other sites

On 5/28/2019 at 11:00 AM, 3fingers said:

Hi @Wanze,

is it possibile to query a ProField Matrix field (an image in this particular case) as a placeholder for the og:image setting? Something like {matrixfield.imagefield} ?

Right now the only images I have inside my templates come from a field of type Matrix.

Any solution available? ?

@3fingers Did you try if it works? I think it won't because the module currently expects an image field on the page, it cannot resolve nested fields. For text based placeholders, this should work, as the module uses ProcessWire's wirePopulateStringTags function which supports nested WireData objects.

One solution would be the one mentioned by @Mikie: To populate the og image URL from your matrix field when saving the page, via hook.
Another possibility is to use a hook provided by the module to modify the OG image url when being rendered, check out the following issue and the linked test cases for the hooks: https://github.com/wanze/SeoMaestro/issues/8

Cheers

  • Like 1
Link to comment
Share on other sites

11 hours ago, Mikie said:

I came to ask a similar question, as mentioned I haven’t even tested this yet so sorry if I missed something ... if you reference a field for the description with large amounts of text does it automatically truncate the text? If not, is there a way to do this in the {field} placeholder, like {field|truncate:200} ? Would be handy.

@Mikie The module does not truncate any texts, I can see this as an additional setting on field level. The truncate filter looks good, but the used function to parse the expression of ProcessWire does not support this kind of filters. Would be way easier if this could be left to a template engine ?

One solution would be to use a hook to truncate the text when rendering:

$wire->addHookAfter('SeoMaestro::renderSeoDataValue', function (HookEvent $event) {
  $group = $event->arguments(0);
  $name = $event->arguments(1);
  $value = $event->arguments(2);
  if ($group === 'meta' && $name === 'description') {
    $event->return = substr($value, 0, 200);
  }
});

Cheers

  • Like 1
Link to comment
Share on other sites

Thanks  @Wanze!

I found my solution :

wire()->addHookAfter('SeoMaestro::renderMetatags', function($event) {
    $tags = $event->return;
    $page = $event->wire('page');

    foreach($tags as $key => $value) {
        if($key == 'image' && $key != '') {
            $matrix_field = $page->matrix->find('type=immagine_singola')->first(); // immagine_singola is my matrix type
            $matrix_image = $matrix_field->immagine_articolo->url(); // immagine_articolo is the field inside
            $tags[$key] = $matrix_image;
        }
    }
});

I have to refactor something, but for now it's ok.

Guys, you rock ?

  • Like 1
Link to comment
Share on other sites

Nice one @3fingers

13 hours ago, Wanze said:

Would be way easier if this could be left to a template engine ?

Thanks @Wanze hook works great. I like this truncate function, simple and works as advertised: https://www.the-art-of-web.com/php/truncate/ 

Regarding the above when you say left to the template engine what do you mean? I assume disable that tag from automatic output by Seo Maestro and add yourself using eg twig filter? 

  • Like 1
Link to comment
Share on other sites

19 hours ago, Mikie said:

Regarding the above when you say left to the template engine what do you mean? I assume disable that tag from automatic output by Seo Maestro and add yourself using eg twig filter? 

I was referring to your example on how to apply a truncate function within the placeholder: {field|truncate:200}
This would be nice but requires a custom implementation because the placeholder-parser of ProcessWire cannot handle this expression. If we had a more sophisticated template engine available, this would be an easy task ?

Link to comment
Share on other sites

I just released version 0.7.0 of the module:

  • It fixes the ugly label being showed above the "inhterit" checkbox for newer Processwire versions. I think there is a bug in core, because ProcessWire ignores the fact that the label is marked as "hidden". I had to fix it via CSS for now.
  • Added the possibility to resize the Opengraph image when referencing a page image by specifying a width and/or height.
  • Opengraph image: If the referenced image field is empty and pulls the image from another page (default value), the module now substitutes the default image as well.

Other than that the readme now contains a chapter for the various hooks provided by SeoMaestro. This might be interesting if you need to customize the behaviour of the module. Please let me know if you find any issues! ?

Cheers

  • Like 5
Link to comment
Share on other sites

Version 0.8.0 has been released:

  • Adds facebook share preview for content editors when editing Opengraph meta data
  • Adds support to extend the rendered meta title with additional information such as the domain or site name (#11)
  • Renders structured data (JSON-LD) for breadcrumbs via new group "structuredData" (#10)
  • Adds new meta group "structuredData" which will handle more types of structured data in the future ?

Happy weekend everyone!

Cheers

  • Like 8
  • Thanks 1
Link to comment
Share on other sites

Hi,

I am struggeling with a problem to set the robots metatags (noIndex, noFollow) within a before page save hook. Here is my code (inside ready.php):

$pages->addHookBefore('save', function($event) {
  $page = $event->arguments('page');
  if($page->template == 'privacy-policy' || $page->template == 'search' || $page->template == 'error') {
			//SEO Maestro
			$page->seo->sitemap->include = 0;
			$page->seo->sitemap->priority = '';
			//How to set robots to no index and no follow
      //???????????
  }
});

I could not figure out a way to accomplish this. Can anyone help me out?

Thanks

Link to comment
Share on other sites

Hello,

Iam just trying to install the module but getting the following error any ideas? :- 

"Parse Error: syntax error, unexpected '?' (line 50 of /home/skyewalkerhostel/public_html/site/modules/SeoMaestro/InputfieldSeoMaestro.module.php) "

Using PHP7.2 & PW 3.0.128

Link to comment
Share on other sites

8 hours ago, Jon said:

Hello,

 Iam just trying to install the module but getting the following error any ideas? :- 

 "Parse Error: syntax error, unexpected '?' (line 50 of /home/skyewalkerhostel/public_html/site/modules/SeoMaestro/InputfieldSeoMaestro.module.php) "

 Using PHP7.2 & PW 3.0.128

The line in question is: 

$isTranslatable = $info['translatable'] ?? false;

The "Null coalescing" operator was introduced with PHP 7 - are you sure you're using PHP 7.2? ? 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

6 hours ago, Wanze said:

The line in question is: 


$isTranslatable = $info['translatable'] ?? false;

The "Null coalescing" operator was introduced with PHP 7 - are you sure you're using PHP 7.2? ? 

Nope Iam no longer sure, turned out to be 5.6 set in cpanel and 7.2 in whm. ?

Thanks for your help ? 

  • Like 1
Link to comment
Share on other sites

Hi @Wanze

Since your breadcrumb addition (0.8), your module is no more compatible with Template Latte Replace module. While I can, in theory prevent the structured_data_breadcrumb template file in the Latte module, this doesn't function. Any idea how to circumvent the problem?

1775827924_Capturedecranle2019-06-26a13_36_19.thumb.png.2c7bfee8236bb3393b7da4094a8673d3.png

Link to comment
Share on other sites

I see. Unfortunately I don't have this issue but perhaps it's a version mismatch or a result of your template setup (I see "controllers" in the path). I can try to reproduce if you tell these details. Anyway, it's sure not SeoMaestro module's fault, maybe this thread could be merged to the main Latte one?

Link to comment
Share on other sites

My programmers prefer to seperate views and controllers, so they configured this in config.php

$config->paths->templates = $sitePath . "templates/controllers/";
//$config->paths->views = $sitePath . "templates/views";

The SEO module was working perfectly well with this until the new version. I will ask in the Latter forum.

Link to comment
Share on other sites

Hi @Wanze, getting an error with 0.8.0 update with the structured data breadcrumb template using TemplateLatteReplace module. Its fine as I can ignore that file with Latte using the module settings, but maybe changes relying on rendering templates like this should default to unchecked, as I assume same issue would occur with other template systems.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...