Jump to content
psy

JSON+LD Schema module

Recommended Posts

This module helps you dynamically create schemas for improved SEO & SERP listings from within your templates. Each schema can be configured to meet your requirements. You can even add your own ProcessWire schema classes to the module.

Read about the module on  github: https://github.com/clipmagic/MarkupJsonLDSchema

Download from github: https://github.com/clipmagic/MarkupJsonLDSchema/zipball/master

Download from ProcessWire modules: http://modules.processwire.com/modules/markup-json-ldschema/

  • Like 14

Share this post


Link to post
Share on other sites

Am I missing something? Where is that module? Do you have a link? Maybe I'm confused by the new forum changes, but I don't see an attachment either...

Share this post


Link to post
Share on other sites

Most of the time people do not only submit the module to the modules directory, but also link to either the module's page in the directory or the github repo (sometimes both) from their forum posts as well. Especially as it seems like your module is by not not approved in the module's directory nobody but you can see it there.

Share this post


Link to post
Share on other sites

OK. Still learning. Thanks.

Submitted module via github and had to open a forum topic as part of that process. Hopefully sorted now.

Let me know if I need to do more to make the module available.

 

Share this post


Link to post
Share on other sites

Links added and closing tags removed.

I updated the version # to 0.0.3 but it is still showing 0.0.2 in the modules directory?

Thank you all for your help. Much appreciated. :)

Share this post


Link to post
Share on other sites

The modules directory visits github once a day. To force it to refresh, just edit the module in the directory, but don't do anything and just save. That forces the crawler to go back to github and voila, you got it updated :)

 

Congrats on your new module btw ^-^

  • Like 2

Share this post


Link to post
Share on other sites

Have not checked out the module yet, but seems like a very nice addition. The JSON+LD Schema is really something Google will be using a lot in the future. Mark my words!

  • Like 1

Share this post


Link to post
Share on other sites

This is a very nice module,  but when I try to validate a LocalBusiness schema using Google Search structured data tester, it don't validate. I got some error message like: Google doesn't recognise property streetAddress for an object of the type LocalBusiness. Same for addressLocality , addressRegion, .... Got the same problem when I try to valicate an article. Thank's for your help!

Share this post


Link to post
Share on other sites
11 hours ago, Pino said:

This is a very nice module,  but when I try to validate a LocalBusiness schema using Google Search structured data tester, it don't validate. I got some error message like: Google doesn't recognise property streetAddress for an object of the type LocalBusiness. Same for addressLocality , addressRegion, .... Got the same problem when I try to valicate an article. Thank's for your help!

Oh, yes you're correct. According to the reference, addresses are associated with Organization, not localBusiness. I will fix and update the module.

https://developers.google.com/schemas/reference/types/Place

https://developers.google.com/schemas/reference/types/LocalBusiness

Thanks for bringing this to my attention.

 

  • Like 1

Share this post


Link to post
Share on other sites

@OllieMackJames

Glad you like it :)

There are way too many schemas for me to include in the basic module. I chose what I thought would be the most useful. However you have a couple of options:

1. Use the custom schema option, eg:

$jsonld = $modules->get("MarkupJsonLDSchema");
$options = array();
$options["@type"] = "VideoObject";
$options["custom"] = array (
  "actor" => "Barney Rubble",
  "caption" => "What an actor!",
  ...
);
?>
<script type="application/ld+json">
  <?php $jsonld->render('Custom',$options); ?>
</script>

OR

2. Write your own schema and add it to the site/modules/MarkupJsonLDSchema/schemas/ directory. See the other schemas in there and their naming conventions as examples, and feel free to include your video schema code in this topic to share with others.


BTW, the link http://jsonld.com/video/ leads to a 404 Error. A much better resource is http://schema.org/VideoObject.

Hope this helps
psy
  
 

  • Like 1

Share this post


Link to post
Share on other sites

Hi @psy,

Thanks for sharing your module!  I've been trying out your module and I'm aware that I don't have to use the default schemas and can use overrides, but I have a few questions:

Share this post


Link to post
Share on other sites

@gmclelland Thanks for the feedback . This was my first module, dipping my toe in so to speak. I found the whole schema thing confusing and the module could definitely do with an update. Have taken your suggestions on board - plus a few other things I've learnt about json-ld schemas in the interim - and hope to release an update in the new year

Share this post


Link to post
Share on other sites

Good to hear psy!  Looking forward to trying it.  I just started learning about JSON-LD, and your module and readme.txt with the links helped point me in the right direction.

19 hours ago, psy said:

I found the whole schema thing confusing

I've found it very confusing as well.  The JSON-LD and Google documentation doesn't exactly say when or what pages you should use Website schema vs Webpage.  Does the Organization markup go on every page, or just the homepage of the website? etc..etc...

  • Like 1

Share this post


Link to post
Share on other sites

I keep getting undefined index 'image'

Tried several ways to get rid of this error.

What is recommended/correct way to add the code for the images in the template?

Share this post


Link to post
Share on other sites

Hello Psy,

I currently have this and it looks like images are outputted

I must have made a stupid mistake somewhere. On another site I got it working in one time.

 

    $jsonld = $modules->get('MarkupJsonLDSchema'); ?>
    <script type="application/ld+json">
<?php
        switch ($page->template) {

            case 'product':

                $options = array(
                    'logo' => $pages->get(1)->logo->size(200, 200),
                    'image' => $page->images->first()->size(200, 200)
                );
                echo $jsonld->render('Product', $options);
                //  echo $jsonld->render('BreadcrumbList');
                break;
            case 'categorieen':
                $options_c = array(
                    'logo' => $pages->get(1)->logo->size(200, 200),
                    'description' => $page->summary,
                    'image' => $pages->get(1092)->images->first()->size(200, 200)
                );
                echo $jsonld->render('Product', $options_c);
                echo $jsonld->render('BreadcrumbList');
                break;
            default:
                $options = array(
                    'logo' => $pages->get(1)->logo->size(200, 200),
                    'image' => $page->images->first()->size(200, 200)
                );
                echo $jsonld->render('WebPage', $options);
                echo $jsonld->render('LocalBusiness');
                echo $jsonld->render('BreadcrumbList');
                break;
        }
        ?>
    
    </script>

Share this post


Link to post
Share on other sites

Thanks for sharing @webhoes

Glad it's working for you.

Schema's are confusing and you can always write your own and add them to the schema dir of the module (and share here of course!)

One thing you may want to check... you're outputting several schemas within one <script> tag... maybe you need to enclose them in brackets, eg:

<script>[
    .... your output schemas ....
]<script>

to show multiple json arrays within one script tag. No expert here and would appreciate comments/recommendations from others.

Cheers

psy

 

 

Share this post


Link to post
Share on other sites

I don't understand them either. Was just working based of the sample's. I googled and it does not seem to matter if you use one block or more. I did quick and dirty fix... looking like this. Note I always have atleast 2 schemes and therefor kinda hardcoded the brackets. There is also a ',' between 2 schemes.

  <?php
    $jsonld = $modules->get('MarkupJsonLDSchema'); ?>
    <script type="application/ld+json">[
<?php
        switch ($page->template) {

            case 'product':

                $options = array(
                    'logo' => $pages->get(1)->logo->size(200, 200),
                    'image' => $page->images->first()->size(200, 200)
                );
                echo $jsonld->render('Product', $options) . ",";
                echo $jsonld->render('BreadcrumbList');
                break;
            case 'categorieen':
                $options_c = array(
                    'logo' => $pages->get(1)->logo->size(200, 200),
                    'description' => $page->summary,
                    'image' => $pages->get(1092)->images->first()->size(200, 200)
                );
                echo $jsonld->render('Product', $options_c) . ",";
                echo $jsonld->render('BreadcrumbList');
                break;
            default:
                $options = array(
                    'logo' => $pages->get(1)->logo->size(200, 200),
                    'image' => $page->images->first()->size(200, 200)
                );
                echo $jsonld->render('WebPage', $options) . ",";
                echo $jsonld->render('LocalBusiness') . ",";
                echo $jsonld->render('BreadcrumbList');
                break;
        }
        ?>

    ]</script>
  • Like 3

Share this post


Link to post
Share on other sites

BTW, if you use width() you get a cached image with name-200-0.jp. That means it has no height and therefor is not really an image. Using size() gets a correct image.

 

 

  • Like 2

Share this post


Link to post
Share on other sites

I was reading a thread about Structured Data, is it possible to use this module to generate the AggregateRating? 

See MarcoPLY example. Thank you.

 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state. "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
    • By louisstephens
      So I have been hard at work creating url segments for a template (api) and everything is working swimmingly in creating a simple end point for svelte.js. I have however, run into a few questions that I can wrap my head around.
      In my api template I have:
      if($input->urlSegment1 === 'clients') { header('Content-Type: application/json'); $clients = $pages->find("template=clients"); $client_array = array(); foreach ($clients as $client) { $id = $client->id; $title = $client->title; $url = $client->url; $clientName = $client->client_name; $clientColor = $client->client_color->value; $assigned = $client->assigned_to->user_full_name; $client_array[] = array( 'id' => $id, 'code' => $title, 'name' => $clientName, 'associated_users' => $assigned, 'url' => $url ); } $client_json = json_encode($client_array, true); echo $client_json; } The output json from this is:
      [ { "id":1644, "code":"abc", "name":"Test Name", "associated_users":null, "url":"\/pw\/clients\/abc\/" }, { "id": 1645, "code": "xyz", "name": "Test Name", "associated_users": null, "url": "\/pw\/clients\/xyz\/" }, ] I was curious is it possible to add in "clients" before this output json so it would appear as 
      clients: [ { "id":1644, "code":"abc", "name":"Test Name", "associated_users":null, "url":"\/pw\/clients\/abc\/" }, { "id": 1645, "code": "xyz", "name": "Test Name", "associated_users": null, "url": "\/pw\/clients\/xyz\/" }, ] I was not really sure of how to tackle this in my php code, and have spent more time than I care to admit trying to figure it out. Another question I have is that "associated_users" is returning null, which in this instance is correct. It is a multi page field that is set to pull a custom name field from the users template, ie "Louis Stephens" would be associated with the first page. I understand that I need to use a foreach to get the correct data, but I was really unsure of how to place this inside an array, or update the array with the new data. Any help with any of this would greatly be appreciated.
    • By adrian
      This module allows you to automatically rename file (including image) uploads according to a configurable format
      This module lets you define as many rules as you need to determine how uploaded files will be named and you can have different rules for different pages, templates, fields, and file extensions, or one rule for all uploads. Renaming works for files uploaded via the admin interface and also via the API, including images added from remote URLs.   Github: https://github.com/adrianbj/CustomUploadNames
      Modules Directory: http://modules.processwire.com/modules/process-custom-upload-names/
      Renaming Rules
      The module config allows you to set an unlimited number of Rename Rules. You can define rules to specific fields, templates, pages, and file extensions. If a rule option is left blank, the rule with be applied to all fields/templates/pages/extensions. Leave Filename Format blank to prevent renaming for a specific field/template/page combo, overriding a more general rule. Rules are processed in order, so put more specific rules before more general ones. You can drag to change the order of rules as needed. The following variables can be used in the filename format: $page, $template, $field, and $file. For some of these (eg. $field->description), if they haven't been filled out and saved prior to uploading the image, renaming won't occur on upload, but will happen on page save (could be an issue if image has already been inserted into RTE/HTML field before page save). Some examples: $page->title mysite-{$template->name}-images $field->label $file->description {$page->name}-{$file->filesize}-kb prefix-[Y-m-d_H-i-s]-suffix (anything inside square brackets is is considered to be a PHP date format for the current date/time) randstring[n] (where n is the number of characters you want in the string) ### (custom number mask, eg. 001 if more than one image with same name on a page. This is an enhanced version of the automatic addition of numbers if required) If 'Rename on Save' is checked files will be renamed again each time a page is saved (admin or front-end via API). WARNING: this setting will break any direct links to the old filename, which is particularly relevant for images inserted into RTE/HTML fields. The Filename Format can be defined using plain text and PW $page variable, for example: mysite-{$page->path} You can preserve the uploaded filename for certain rules. This will allow you to set a general renaming rule for your entire site, but then add a rule for a specific page/template/field that does not rename the uploaded file. Just simply build the rule, but leave the Filename Format field empty. You can specify an optional character limit (to nearest whole word) for the length of the filename - useful if you are using $page->path, $path->name etc and have very long page names - eg. news articles, publication titles etc. NOTE - if you are using ProcessWire's webp features, be sure to use the useSrcExt because if you have jpg and png files on the same page and your rename rules result in the same name, you need to maintain the src extension so they are kept as separate files.
      $config->webpOptions = array(     'useSrcExt' => false, // Use source file extension in webp filename? (file.jpg.webp rather than file.webp) ); Acknowledgments
      The module config settings make use of code from Pete's EmailToPage module and the renaming function is based on this code from Ryan: http://processwire.com/talk/topic/3299-ability-to-define-convention-for-image-and-file-upload-names/?p=32623 (also see this post for his thoughts on file renaming and why it is the lazy way out - worth a read before deciding to use this module). 
       
       
      NOTE:
      This should not be needed on most sites, but I work with lots of sites that host PDFs and photos/vectors that are available for download and I have always renamed the files on upload because clients will often upload files with horrible meaningless filenames like:
      Final ReportV6 web version for John Feb 23.PDF

×
×
  • Create New...